aboutsummaryrefslogtreecommitdiffstats
path: root/tests/tree
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2013-06-11 16:16:17 +0200
committerJoas Schilling <nickvergessen@gmx.de>2013-06-11 16:16:17 +0200
commitd5f651c51406fb71dd5075be8a33a904aa570450 (patch)
tree30862b4bb1823b757ca29341487ee8ba55588f39 /tests/tree
parent6f86c1dc7643c8f6928cb4f33322bc4447c0b9fc (diff)
downloadforums-d5f651c51406fb71dd5075be8a33a904aa570450.tar
forums-d5f651c51406fb71dd5075be8a33a904aa570450.tar.gz
forums-d5f651c51406fb71dd5075be8a33a904aa570450.tar.bz2
forums-d5f651c51406fb71dd5075be8a33a904aa570450.tar.xz
forums-d5f651c51406fb71dd5075be8a33a904aa570450.zip
[ticket/11599] Copy the forums into a static array for later reuse
PHPBB3-11599
Diffstat (limited to 'tests/tree')
-rw-r--r--tests/tree/nestedset_forum_base.php59
1 files changed, 42 insertions, 17 deletions
diff --git a/tests/tree/nestedset_forum_base.php b/tests/tree/nestedset_forum_base.php
index 776e822280..43680609f8 100644
--- a/tests/tree/nestedset_forum_base.php
+++ b/tests/tree/nestedset_forum_base.php
@@ -59,27 +59,52 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case
$this->set = new phpbb_tree_nestedset_forum($this->db, $this->lock, 'phpbb_forums');
$this->set_up_forums();
-
- $sql = "UPDATE phpbb_forums
- SET forum_parents = 'a:0:{}'";
- $this->db->sql_query($sql);
}
protected function set_up_forums()
{
- $this->create_forum('Parent with two flat children');
- $this->create_forum('Flat child #1', 1);
- $this->create_forum('Flat child #2', 1);
-
- $this->create_forum('Parent with two nested children');
- $this->create_forum('Nested child #1', 4);
- $this->create_forum('Nested child #2', 5);
-
- $this->create_forum('Parent with flat and nested children');
- $this->create_forum('Mixed child #1', 7);
- $this->create_forum('Mixed child #2', 7);
- $this->create_forum('Nested child #1 of Mixed child #2', 9);
- $this->create_forum('Mixed child #3', 7);
+ static $forums;
+
+ if (empty($forums))
+ {
+ $this->create_forum('Parent with two flat children');
+ $this->create_forum('Flat child #1', 1);
+ $this->create_forum('Flat child #2', 1);
+
+ $this->create_forum('Parent with two nested children');
+ $this->create_forum('Nested child #1', 4);
+ $this->create_forum('Nested child #2', 5);
+
+ $this->create_forum('Parent with flat and nested children');
+ $this->create_forum('Mixed child #1', 7);
+ $this->create_forum('Mixed child #2', 7);
+ $this->create_forum('Nested child #1 of Mixed child #2', 9);
+ $this->create_forum('Mixed child #3', 7);
+
+ // Updating forum_parents column here so it's not empty
+ // This is required, so we can see whether the methods
+ // correctly clear the values.
+ $sql = "UPDATE phpbb_forums
+ SET forum_parents = 'a:0:{}'";
+ $this->db->sql_query($sql);
+
+ // Copy the forums into a static array, so we can reuse the list later
+ $sql = 'SELECT *
+ FROM phpbb_forums';
+ $result = $this->db->sql_query($sql);
+ $forums = $this->db->sql_fetchrowset($result);
+ $this->db->sql_freeresult($result);
+ }
+ else
+ {
+ $buffer = new phpbb_db_sql_insert_buffer($this->db, 'phpbb_forums');
+ $buffer->insert_all($forums);
+ $buffer->flush();
+
+ $this->database_synchronisation(array(
+ 'phpbb_forums' => array('forum_id'),
+ ));
+ }
}
protected function create_forum($name, $parent_id = 0)