diff options
Diffstat (limited to 'modules/tag/tests')
-rw-r--r-- | modules/tag/tests/Tag_Test.php | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/modules/tag/tests/Tag_Test.php b/modules/tag/tests/Tag_Test.php index 989efb3c..0a7f878c 100644 --- a/modules/tag/tests/Tag_Test.php +++ b/modules/tag/tests/Tag_Test.php @@ -38,5 +38,43 @@ class Tag_Test extends Unit_Test_Case { $tag = ORM::factory("tag")->where("name", $tag1)->find(); $this->assert_true(2, $tag->count); } - // @todo put some tests here + + public function load_buckets_test() { + + $tags = array(); + for ($tag_count = 1; $tag_count <= 8; $tag_count++) { + $rand = rand(); + $album = album::create(1, $rand, $rand, $rand); + for ($idx = 0; $idx < $tag_count; $idx++) { + tag::add($album, "tag$idx"); + } + } + + $tag_list = tag::load_buckets(); + Kohana::log("debug", print_r($tag_list, true)); + $expected_tag_list = array( + array("name" => "tag0", "count" => 8, "class" => 5), + array("name" => "tag1", "count" => 9, "class" => 6), + array("name" => "tag2", "count" => 6, "class" => 4), + array("name" => "tag3", "count" => 5, "class" => 3), + array("name" => "tag4", "count" => 4, "class" => 2), + array("name" => "tag5", "count" => 3, "class" => 1), + array("name" => "tag6", "count" => 2, "class" => 0), + array("name" => "tag7", "count" => 1, "class" => 0) + ); + $this->assert_equal($expected_tag_list, $tag_list, "incorrect non filtered tag list"); + + $tag_list = tag::load_buckets(2); + Kohana::log("debug", print_r($tag_list, true)); + $expected_tag_list = array( + array("name" => "tag0", "count" => 8, "class" => 5), + array("name" => "tag1", "count" => 9, "class" => 6), + array("name" => "tag2", "count" => 6, "class" => 4), + array("name" => "tag3", "count" => 5, "class" => 3), + array("name" => "tag4", "count" => 4, "class" => 2), + array("name" => "tag5", "count" => 3, "class" => 1), + array("name" => "tag6", "count" => 2, "class" => 0) + ); + $this->assert_equal($expected_tag_list, $tag_list, "incorrect filtered tag list"); + } }
\ No newline at end of file |