From 936decb437cbb19799dcae255af1d4425a850ae3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 7 Nov 2008 06:46:38 +0000 Subject: Add children_count() to ORM_MPTT --- core/tests/ORM_MPTT_Test.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'core/tests') diff --git a/core/tests/ORM_MPTT_Test.php b/core/tests/ORM_MPTT_Test.php index a543c1cd..d66006f5 100644 --- a/core/tests/ORM_MPTT_Test.php +++ b/core/tests/ORM_MPTT_Test.php @@ -69,4 +69,29 @@ class ORM_MPTT_Test extends Unit_Test_Case { } $this->assert_equal(array($inner1->id, $inner2->id), $child_ids); } + + public function children_limit_test() { + $outer = ORM::factory("item"); + $outer->add_to_parent(1); + + $inner1 = ORM::factory("item"); + $inner1->add_to_parent($outer->id); + + $inner2 = ORM::factory("item"); + $inner2->add_to_parent($outer->id); + + $this->assert_equal(array($inner2->id => null), $outer->children(1, 1)->select_list('id')); + } + + public function children_count_test() { + $outer = ORM::factory("item"); + $outer->add_to_parent(1); + + $inner1 = ORM::factory("item"); + $inner1->add_to_parent($outer->id); + + $inner2 = ORM::factory("item"); + $inner2->add_to_parent($outer->id); + $this->assert_equal(2, $outer->children_count()); + } } -- cgit v1.2.3