summaryrefslogtreecommitdiff
path: root/core/tests/ORM_MPTT_Test.php
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2008-11-20 06:05:22 +0000
committerTim Almdal <tnalmdal@shaw.ca>2008-11-20 06:05:22 +0000
commit6fd261c8b02c90d6a24d12b10e5bd20a0adb4734 (patch)
tree636a509d14c6e453ef218c62d60c48592708380d /core/tests/ORM_MPTT_Test.php
parent4c587bdb01e6a7664780c53518a8cbe2858741b3 (diff)
Add unittest and caching for ORM_MTPP::descendants
Diffstat (limited to 'core/tests/ORM_MPTT_Test.php')
-rw-r--r--core/tests/ORM_MPTT_Test.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/core/tests/ORM_MPTT_Test.php b/core/tests/ORM_MPTT_Test.php
index a053b61e..2b334243 100644
--- a/core/tests/ORM_MPTT_Test.php
+++ b/core/tests/ORM_MPTT_Test.php
@@ -95,6 +95,42 @@ class ORM_MPTT_Test extends Unit_Test_Case {
$this->assert_equal(2, $outer->children_count());
}
+ public function descendant_test() {
+ $parent = album::create(1, "parent album", "parent album title");
+ photo::create($parent->id, DOCROOT . "themes/default/images/thumbnail.jpg", "photo1",
+ "photo1", "parent album photo");
+
+ $album1 = album::create($parent->id, "album1", "album1 title");
+ photo::create($album1->id, DOCROOT . "themes/default/images/thumbnail.jpg", "photo1",
+ "photo1", "album1 photo");
+
+ $album2 = album::create($parent->id, "album2", "album2 title");
+ photo::create($album2->id, DOCROOT . "themes/default/images/thumbnail.jpg", "photo2",
+ "photo2", "album2 photo");
+ $parent->reload();
+
+ $this->assert_equal(5, $parent->descendants()->count());
+ $this->assert_equal(3, $parent->descendants(null, 0, "photo")->count());
+ $this->assert_equal(2, $parent->descendants(null, 0, "album")->count());
+ }
+
+ public function descendant_limit_test() {
+ $parent = album::create(1, "parent album", "parent album title");
+ photo::create($parent->id, DOCROOT . "themes/default/images/thumbnail.jpg", "photo1",
+ "photo1", "parent album photo");
+
+ $album1 = album::create($parent->id, "album1", "album1 title");
+ photo::create($album1->id, DOCROOT . "themes/default/images/thumbnail.jpg", "photo1",
+ "photo1", "album1 photo");
+
+ $album2 = album::create($parent->id, "album2", "album2 title");
+ photo::create($album2->id, DOCROOT . "themes/default/images/thumbnail.jpg", "photo2",
+ "photo2", "album2 photo");
+ $parent->reload();
+
+ $this->assert_equal(2, $parent->descendants(2)->count());
+ }
+
public function descendant_count_test() {
$parent = album::create(1, "parent album", "parent album title");
photo::create($parent->id, DOCROOT . "themes/default/images/thumbnail.jpg", "photo1",