diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2008-11-20 05:06:24 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2008-11-20 05:06:24 +0000 |
commit | 604e58346bdbb99fa62f53aa21d37f0d239b93fc (patch) | |
tree | 32c62505612b5e54e343f53d9612ec6b38a49a57 /core/tests/ORM_MPTT_Test.php | |
parent | 29cc48ebcf2f8c267a41815cb1cf0ea11f7326e2 (diff) |
Add unittest and caching to ORM_MTPP::descendants_count
Diffstat (limited to 'core/tests/ORM_MPTT_Test.php')
-rw-r--r-- | core/tests/ORM_MPTT_Test.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/tests/ORM_MPTT_Test.php b/core/tests/ORM_MPTT_Test.php index d66006f5..a053b61e 100644 --- a/core/tests/ORM_MPTT_Test.php +++ b/core/tests/ORM_MPTT_Test.php @@ -94,4 +94,23 @@ class ORM_MPTT_Test extends Unit_Test_Case { $inner2->add_to_parent($outer->id); $this->assert_equal(2, $outer->children_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", + "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_count("photo")); + $this->assert_equal(2, $parent->descendants_count("album")); + } } |