From 499dd3a833912d07fe677ae721e99678708bddcd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 25 Apr 2013 17:13:21 +0200 Subject: [ticket/11495] Move tests to tree/ directory PHPBB3-11495 --- tests/tree/nestedset_forum_get_data_test.php | 117 +++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 tests/tree/nestedset_forum_get_data_test.php (limited to 'tests/tree/nestedset_forum_get_data_test.php') diff --git a/tests/tree/nestedset_forum_get_data_test.php b/tests/tree/nestedset_forum_get_data_test.php new file mode 100644 index 0000000000..4ce679f05d --- /dev/null +++ b/tests/tree/nestedset_forum_get_data_test.php @@ -0,0 +1,117 @@ +assertEquals($expected, array_keys($this->set->get_full_branch_data($forum_id, $order_desc, $include_item))); + } + + public function get_parent_branch_data_data() + { + return array( + array(1, true, true, array(1)), + array(1, true, false, array()), + array(1, false, true, array(1)), + array(1, false, false, array()), + + array(2, true, true, array(1, 2)), + array(2, true, false, array(1)), + array(2, false, true, array(2, 1)), + array(2, false, false, array(1)), + + array(5, true, true, array(4, 5)), + array(5, true, false, array(4)), + array(5, false, true, array(5, 4)), + array(5, false, false, array(4)), + ); + } + + /** + * @dataProvider get_parent_branch_data_data + */ + public function test_get_parent_branch_data($forum_id, $order_desc, $include_item, $expected) + { + $this->assertEquals($expected, array_keys($this->set->get_parent_branch_data($forum_id, $order_desc, $include_item))); + } + + public function get_children_branch_data_data() + { + return array( + array(1, true, true, array(1, 2, 3)), + array(1, true, false, array(2, 3)), + array(1, false, true, array(3, 2, 1)), + array(1, false, false, array(3, 2)), + + array(2, true, true, array(2)), + array(2, true, false, array()), + array(2, false, true, array(2)), + array(2, false, false, array()), + + array(5, true, true, array(5, 6)), + array(5, true, false, array(6)), + array(5, false, true, array(6, 5)), + array(5, false, false, array(6)), + ); + } + + /** + * @dataProvider get_children_branch_data_data + */ + public function test_get_children_branch_data($forum_id, $order_desc, $include_item, $expected) + { + $this->assertEquals($expected, array_keys($this->set->get_children_branch_data($forum_id, $order_desc, $include_item))); + } + + public function get_parent_data_data() + { + return array( + array(1, array(), array()), + array(1, array('forum_parents' => serialize(array())), array()), + array(2, array(), array(1)), + array(2, array('forum_parents' => serialize(array(1 => array()))), array(1)), + array(10, array(), array(7, 9)), + array(10, array('forum_parents' => serialize(array(7 => array(), 9 => array()))), array(7, 9)), + ); + } + + /** + * @dataProvider get_parent_data_data + */ + public function test_get_parent_data($forum_id, $forum_data, $expected) + { + $this->assertEquals($expected, array_keys($this->set->get_parent_data(array_merge($this->forum_data[$forum_id], $forum_data)))); + } +} -- cgit v1.2.1 From ce07b2776577d1ed3987b38e231a367cfef21db6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 25 Apr 2013 17:27:33 +0200 Subject: [ticket/11495] Fix failing unit tests PHPBB3-11495 --- tests/tree/nestedset_forum_get_data_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/tree/nestedset_forum_get_data_test.php') diff --git a/tests/tree/nestedset_forum_get_data_test.php b/tests/tree/nestedset_forum_get_data_test.php index 4ce679f05d..24ada93409 100644 --- a/tests/tree/nestedset_forum_get_data_test.php +++ b/tests/tree/nestedset_forum_get_data_test.php @@ -7,7 +7,7 @@ * */ -require_once dirname(__FILE__) . '/set_forum_base.php'; +require_once dirname(__FILE__) . '/nestedset_forum_base.php'; class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_nestedset_forum_base { -- cgit v1.2.1 From baff4287e5a7142b7af41e56c29b064bb56fd7fb Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 25 Apr 2013 22:39:24 +0200 Subject: [ticket/11495] Fix comments and package docs PHPBB3-11495 --- tests/tree/nestedset_forum_get_data_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/tree/nestedset_forum_get_data_test.php') diff --git a/tests/tree/nestedset_forum_get_data_test.php b/tests/tree/nestedset_forum_get_data_test.php index 24ada93409..71c1d8bf8a 100644 --- a/tests/tree/nestedset_forum_get_data_test.php +++ b/tests/tree/nestedset_forum_get_data_test.php @@ -1,7 +1,7 @@ Date: Tue, 30 Apr 2013 10:32:01 +0200 Subject: [ticket/11495] Fix some docs and replace branch with other terms PHPBB3-11495 --- tests/tree/nestedset_forum_get_data_test.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'tests/tree/nestedset_forum_get_data_test.php') diff --git a/tests/tree/nestedset_forum_get_data_test.php b/tests/tree/nestedset_forum_get_data_test.php index 71c1d8bf8a..300bbc6bfa 100644 --- a/tests/tree/nestedset_forum_get_data_test.php +++ b/tests/tree/nestedset_forum_get_data_test.php @@ -11,7 +11,7 @@ require_once dirname(__FILE__) . '/nestedset_forum_base.php'; class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_nestedset_forum_base { - public function get_full_branch_data_data() + public function get_path_and_subtree_data_data() { return array( array(1, true, true, array(1, 2, 3)), @@ -32,14 +32,14 @@ class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_ne } /** - * @dataProvider get_full_branch_data_data + * @dataProvider get_path_and_subtree_data_data */ - public function test_get_full_branch_data($forum_id, $order_desc, $include_item, $expected) + public function test_get_path_and_subtree_data($forum_id, $order_desc, $include_item, $expected) { - $this->assertEquals($expected, array_keys($this->set->get_full_branch_data($forum_id, $order_desc, $include_item))); + $this->assertEquals($expected, array_keys($this->set->get_path_and_subtree_data($forum_id, $order_desc, $include_item))); } - public function get_parent_branch_data_data() + public function get_path_data_data() { return array( array(1, true, true, array(1)), @@ -60,14 +60,14 @@ class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_ne } /** - * @dataProvider get_parent_branch_data_data + * @dataProvider get_path_data_data */ - public function test_get_parent_branch_data($forum_id, $order_desc, $include_item, $expected) + public function test_get_path_data($forum_id, $order_desc, $include_item, $expected) { - $this->assertEquals($expected, array_keys($this->set->get_parent_branch_data($forum_id, $order_desc, $include_item))); + $this->assertEquals($expected, array_keys($this->set->get_path_data($forum_id, $order_desc, $include_item))); } - public function get_children_branch_data_data() + public function get_subtree_data_data() { return array( array(1, true, true, array(1, 2, 3)), @@ -88,11 +88,11 @@ class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_ne } /** - * @dataProvider get_children_branch_data_data + * @dataProvider get_subtree_data_data */ - public function test_get_children_branch_data($forum_id, $order_desc, $include_item, $expected) + public function test_get_subtree_data($forum_id, $order_desc, $include_item, $expected) { - $this->assertEquals($expected, array_keys($this->set->get_children_branch_data($forum_id, $order_desc, $include_item))); + $this->assertEquals($expected, array_keys($this->set->get_subtree_data($forum_id, $order_desc, $include_item))); } public function get_parent_data_data() -- cgit v1.2.1 From 4810c61fd7b912ea2914b99f7db502b6f503068f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Apr 2013 10:37:59 +0200 Subject: [ticket/11495] Remove get_parent_data from interface and rename it The method is implementation specific and has no use, apart from cache, that is not covered by get_path_data(). PHPBB3-11495 --- tests/tree/nestedset_forum_get_data_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/tree/nestedset_forum_get_data_test.php') diff --git a/tests/tree/nestedset_forum_get_data_test.php b/tests/tree/nestedset_forum_get_data_test.php index 300bbc6bfa..7a4fada880 100644 --- a/tests/tree/nestedset_forum_get_data_test.php +++ b/tests/tree/nestedset_forum_get_data_test.php @@ -95,7 +95,7 @@ class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_ne $this->assertEquals($expected, array_keys($this->set->get_subtree_data($forum_id, $order_desc, $include_item))); } - public function get_parent_data_data() + public function get_path_basic_data_data() { return array( array(1, array(), array()), @@ -108,10 +108,10 @@ class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_ne } /** - * @dataProvider get_parent_data_data + * @dataProvider get_path_basic_data_data */ - public function test_get_parent_data($forum_id, $forum_data, $expected) + public function test_get_path_basic_data($forum_id, $forum_data, $expected) { - $this->assertEquals($expected, array_keys($this->set->get_parent_data(array_merge($this->forum_data[$forum_id], $forum_data)))); + $this->assertEquals($expected, array_keys($this->set->get_path_basic_data(array_merge($this->forum_data[$forum_id], $forum_data)))); } } -- cgit v1.2.1 From 67f2edae170576104e619ffb38672cabf44e20fa Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Apr 2013 13:54:50 +0200 Subject: [ticket/11495] Use descendants and ancestors instead of parents/children PHPBB3-11495 --- tests/tree/nestedset_forum_get_data_test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/tree/nestedset_forum_get_data_test.php') diff --git a/tests/tree/nestedset_forum_get_data_test.php b/tests/tree/nestedset_forum_get_data_test.php index 7a4fada880..49586fbade 100644 --- a/tests/tree/nestedset_forum_get_data_test.php +++ b/tests/tree/nestedset_forum_get_data_test.php @@ -34,9 +34,9 @@ class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_ne /** * @dataProvider get_path_and_subtree_data_data */ - public function test_get_path_and_subtree_data($forum_id, $order_desc, $include_item, $expected) + public function test_get_path_and_subtree_data($forum_id, $order_asc, $include_item, $expected) { - $this->assertEquals($expected, array_keys($this->set->get_path_and_subtree_data($forum_id, $order_desc, $include_item))); + $this->assertEquals($expected, array_keys($this->set->get_path_and_subtree_data($forum_id, $order_asc, $include_item))); } public function get_path_data_data() @@ -62,9 +62,9 @@ class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_ne /** * @dataProvider get_path_data_data */ - public function test_get_path_data($forum_id, $order_desc, $include_item, $expected) + public function test_get_path_data($forum_id, $order_asc, $include_item, $expected) { - $this->assertEquals($expected, array_keys($this->set->get_path_data($forum_id, $order_desc, $include_item))); + $this->assertEquals($expected, array_keys($this->set->get_path_data($forum_id, $order_asc, $include_item))); } public function get_subtree_data_data() @@ -90,9 +90,9 @@ class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_ne /** * @dataProvider get_subtree_data_data */ - public function test_get_subtree_data($forum_id, $order_desc, $include_item, $expected) + public function test_get_subtree_data($forum_id, $order_asc, $include_item, $expected) { - $this->assertEquals($expected, array_keys($this->set->get_subtree_data($forum_id, $order_desc, $include_item))); + $this->assertEquals($expected, array_keys($this->set->get_subtree_data($forum_id, $order_asc, $include_item))); } public function get_path_basic_data_data() -- cgit v1.2.1 From 863d0c7687cc926dfda0ddd20b34e7942748fb2e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Apr 2013 14:36:26 +0200 Subject: [ticket/11495] Fix some more comments and the package tag PHPBB3-11495 --- tests/tree/nestedset_forum_get_data_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/tree/nestedset_forum_get_data_test.php') diff --git a/tests/tree/nestedset_forum_get_data_test.php b/tests/tree/nestedset_forum_get_data_test.php index 49586fbade..76c99650aa 100644 --- a/tests/tree/nestedset_forum_get_data_test.php +++ b/tests/tree/nestedset_forum_get_data_test.php @@ -1,7 +1,7 @@ Date: Tue, 30 Apr 2013 18:05:44 +0200 Subject: [ticket/11495] Add proper testing of item_parent to tests PHPBB3-11495 --- tests/tree/nestedset_forum_get_data_test.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'tests/tree/nestedset_forum_get_data_test.php') diff --git a/tests/tree/nestedset_forum_get_data_test.php b/tests/tree/nestedset_forum_get_data_test.php index 76c99650aa..ca1863e55e 100644 --- a/tests/tree/nestedset_forum_get_data_test.php +++ b/tests/tree/nestedset_forum_get_data_test.php @@ -98,20 +98,22 @@ class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_ne public function get_path_basic_data_data() { return array( - array(1, array(), array()), - array(1, array('forum_parents' => serialize(array())), array()), - array(2, array(), array(1)), - array(2, array('forum_parents' => serialize(array(1 => array()))), array(1)), - array(10, array(), array(7, 9)), - array(10, array('forum_parents' => serialize(array(7 => array(), 9 => array()))), array(7, 9)), + array(1, '', array()), + array(1, serialize(array()), array()), + array(2, '', array(1)), + array(2, serialize(array(1 => array())), array(1)), + array(10, '', array(7, 9)), + array(10, serialize(array(7 => array(), 9 => array())), array(7, 9)), ); } /** * @dataProvider get_path_basic_data_data */ - public function test_get_path_basic_data($forum_id, $forum_data, $expected) + public function test_get_path_basic_data($forum_id, $forum_parents, $expected) { - $this->assertEquals($expected, array_keys($this->set->get_path_basic_data(array_merge($this->forum_data[$forum_id], $forum_data)))); + $forum_data = $this->forum_data[$forum_id]; + $forum_data['forum_parents'] = $forum_parents; + $this->assertEquals($expected, array_keys($this->set->get_path_basic_data($forum_data))); } } -- cgit v1.2.1