diff options
Diffstat (limited to 'core/tests')
-rw-r--r-- | core/tests/Access_Helper_Test.php | 26 | ||||
-rw-r--r-- | core/tests/Album_Helper_Test.php | 14 | ||||
-rw-r--r-- | core/tests/Items_Controller_Test.php | 6 | ||||
-rw-r--r-- | core/tests/ORM_MPTT_Test.php | 11 | ||||
-rw-r--r-- | core/tests/Photo_Helper_Test.php | 21 | ||||
-rw-r--r-- | core/tests/Var_Test.php | 9 |
6 files changed, 45 insertions, 42 deletions
diff --git a/core/tests/Access_Helper_Test.php b/core/tests/Access_Helper_Test.php index 3141078d..6177723b 100644 --- a/core/tests/Access_Helper_Test.php +++ b/core/tests/Access_Helper_Test.php @@ -84,7 +84,7 @@ class Access_Helper_Test extends Unit_Test_Case { public function new_photos_inherit_parent_permissions_test() { $root = ORM::factory("item", 1); - $album = album::create($root->id, rand(), "test album"); + $album = album::create($root, rand(), "test album"); access::allow(group::everybody(), "view", $album); $photo = ORM::factory("item"); @@ -97,7 +97,7 @@ class Access_Helper_Test extends Unit_Test_Case { public function can_allow_deny_and_reset_intent_test() { $root = ORM::factory("item", 1); - $album = album::create($root->id, rand(), "test album"); + $album = album::create($root, rand(), "test album"); $intent = ORM::factory("access_intent")->where("item_id", $album)->find(); // Allow @@ -149,7 +149,7 @@ class Access_Helper_Test extends Unit_Test_Case { public function cant_view_child_of_hidden_parent_test() { $root = ORM::factory("item", 1); - $album = album::create($root->id, rand(), "test album"); + $album = album::create($root, rand(), "test album"); $root->reload(); access::deny(group::everybody(), "view", $root); @@ -161,7 +161,7 @@ class Access_Helper_Test extends Unit_Test_Case { public function view_permissions_propagate_down_test() { $root = ORM::factory("item", 1); - $album = album::create($root->id, rand(), "test album"); + $album = album::create($root, rand(), "test album"); access::allow(group::everybody(), "view", $root); access::reset(group::everybody(), "view", $album); @@ -171,10 +171,10 @@ class Access_Helper_Test extends Unit_Test_Case { public function can_toggle_view_permissions_propagate_down_test() { $root = ORM::factory("item", 1); - $album1 = album::create($root->id, rand(), "test album"); - $album2 = album::create($album1->id, rand(), "test album"); - $album3 = album::create($album2->id, rand(), "test album"); - $album4 = album::create($album3->id, rand(), "test album"); + $album1 = album::create($root, rand(), "test album"); + $album2 = album::create($album1, rand(), "test album"); + $album3 = album::create($album2, rand(), "test album"); + $album4 = album::create($album3, rand(), "test album"); $album1->reload(); $album2->reload(); @@ -197,7 +197,7 @@ class Access_Helper_Test extends Unit_Test_Case { public function revoked_view_permissions_cant_be_allowed_lower_down_test() { $root = ORM::factory("item", 1); - $album = album::create($root->id, rand(), "test album"); + $album = album::create($root, rand(), "test album"); $root->reload(); access::deny(group::everybody(), "view", $root); @@ -215,7 +215,7 @@ class Access_Helper_Test extends Unit_Test_Case { public function non_view_permissions_propagate_down_test() { $root = ORM::factory("item", 1); - $album = album::create($root->id, rand(), "test album"); + $album = album::create($root, rand(), "test album"); access::allow(group::everybody(), "edit", $root); access::reset(group::everybody(), "edit", $album); @@ -224,11 +224,11 @@ class Access_Helper_Test extends Unit_Test_Case { public function non_view_permissions_can_be_revoked_lower_down_test() { $root = ORM::factory("item", 1); - $outer = album::create($root->id, rand(), "test album"); + $outer = album::create($root, rand(), "test album"); $outer_photo = ORM::factory("item")->add_to_parent($outer); access::add_item($outer_photo); - $inner = album::create($outer->id, rand(), "test album"); + $inner = album::create($outer, rand(), "test album"); $inner_photo = ORM::factory("item")->add_to_parent($inner); access::add_item($inner_photo); @@ -272,7 +272,7 @@ class Access_Helper_Test extends Unit_Test_Case { public function everybody_view_permission_maintains_htaccess_files_test() { $root = ORM::factory("item", 1); - $album = album::create($root->id, rand(), "test album"); + $album = album::create($root, rand(), "test album"); $this->assert_false(file_exists($album->file_path() . "/.htaccess")); diff --git a/core/tests/Album_Helper_Test.php b/core/tests/Album_Helper_Test.php index 1d9388d9..d085ca88 100644 --- a/core/tests/Album_Helper_Test.php +++ b/core/tests/Album_Helper_Test.php @@ -20,7 +20,8 @@ class Album_Helper_Test extends Unit_Test_Case { public function create_album_test() { $rand = rand(); - $album = album::create(1, $rand, $rand, $rand); + $root = ORM::factory("item", 1); + $album = album::create($root, $rand, $rand, $rand); $this->assert_equal(VARPATH . "albums/$rand", $album->file_path()); $this->assert_equal(VARPATH . "thumbs/$rand/.album.jpg", $album->thumb_path()); @@ -38,20 +39,23 @@ class Album_Helper_Test extends Unit_Test_Case { public function create_conflicting_album_test() { $rand = rand(); - $album1 = album::create(1, $rand, $rand, $rand); - $album2 = album::create(1, $rand, $rand, $rand); + $root = ORM::factory("item", 1); + $album1 = album::create($root, $rand, $rand, $rand); + $album2 = album::create($root, $rand, $rand, $rand); $this->assert_true($album1->name != $album2->name); } public function thumb_url_test() { $rand = rand(); - $album = album::create(1, $rand, $rand, $rand); + $root = ORM::factory("item", 1); + $album = album::create($root, $rand, $rand, $rand); $this->assert_equal("http://./var/thumbs/$rand/.album.jpg", $album->thumb_url()); } public function resize_url_test() { $rand = rand(); - $album = album::create(1, $rand, $rand, $rand); + $root = ORM::factory("item", 1); + $album = album::create($root, $rand, $rand, $rand); $this->assert_equal("http://./var/resizes/$rand/.album.jpg", $album->resize_url()); } } diff --git a/core/tests/Items_Controller_Test.php b/core/tests/Items_Controller_Test.php index 784177b5..85ff3e03 100644 --- a/core/tests/Items_Controller_Test.php +++ b/core/tests/Items_Controller_Test.php @@ -20,7 +20,8 @@ class Items_Controller_Test extends Unit_Test_Case { public function change_item_test() { $controller = new Items_Controller(); - $album = album::create(1, "test", "test"); + $root = ORM::factory("item", 1); + $album = album::create($root, "test", "test"); $_POST["title"] = "new title"; $_POST["description"] = "new description"; @@ -31,7 +32,8 @@ class Items_Controller_Test extends Unit_Test_Case { public function change_item_test_with_return() { $controller = new Items_Controller(); - $album = album::create(1, "test", "test"); + $root = ORM::factory("item", 1); + $album = album::create($root, "test", "test"); $_POST["title"] = "item_title"; $_POST["description"] = "item_description"; $_POST["__return"] = "item_description"; diff --git a/core/tests/ORM_MPTT_Test.php b/core/tests/ORM_MPTT_Test.php index b969e287..36f1d78b 100644 --- a/core/tests/ORM_MPTT_Test.php +++ b/core/tests/ORM_MPTT_Test.php @@ -59,11 +59,12 @@ class ORM_MPTT_Test extends Unit_Test_Case { } public function move_to_test() { - $album1 = album::create(1, "move_to_test_1", "move_to_test_1"); - $album1_1 = album::create($album1->id, "move_to_test_1_1", "move_to_test_1_1"); - $album1_2 = album::create($album1->id, "move_to_test_1_2", "move_to_test_1_2"); - $album1_1_1 = album::create($album1_1->id, "move_to_test_1_1_1", "move_to_test_1_1_1"); - $album1_1_2 = album::create($album1_1->id, "move_to_test_1_1_2", "move_to_test_1_1_2"); + $root = ORM::factory("item", 1); + $album1 = album::create($root, "move_to_test_1", "move_to_test_1"); + $album1_1 = album::create($album1, "move_to_test_1_1", "move_to_test_1_1"); + $album1_2 = album::create($album1, "move_to_test_1_2", "move_to_test_1_2"); + $album1_1_1 = album::create($album1_1, "move_to_test_1_1_1", "move_to_test_1_1_1"); + $album1_1_2 = album::create($album1_1, "move_to_test_1_1_2", "move_to_test_1_1_2"); $album1_2->reload(); $album1_1_1->reload(); diff --git a/core/tests/Photo_Helper_Test.php b/core/tests/Photo_Helper_Test.php index f31509a3..2219a846 100644 --- a/core/tests/Photo_Helper_Test.php +++ b/core/tests/Photo_Helper_Test.php @@ -24,7 +24,8 @@ class Photo_Helper_Test extends Unit_Test_Case { $filename = DOCROOT . "core/tests/test.jpg"; $image_info = getimagesize($filename); - $photo = photo::create(1, $filename, "$rand.jpg", $rand, $rand); + $root = ORM::factory("item", 1); + $photo = photo::create($root, $filename, "$rand.jpg", $rand, $rand); $this->assert_equal(VARPATH . "albums/$rand.jpg", $photo->file_path()); $this->assert_equal(VARPATH . "thumbs/{$rand}.jpg", $photo->thumb_path()); @@ -34,7 +35,7 @@ class Photo_Helper_Test extends Unit_Test_Case { $this->assert_true(is_file($photo->resize_path()), "missing: {$photo->resize_path()}"); $this->assert_true(is_file($photo->thumb_path()), "missing: {$photo->thumb_path()}"); - $this->assert_equal(1, $photo->parent_id); // MPTT tests will cover other hierarchy checks + $this->assert_equal($root, $photo->parent_id); // MPTT tests will cover other hierarchy checks $this->assert_equal("$rand.jpg", $photo->name); $this->assert_equal($rand, $photo->title); $this->assert_equal($rand, $photo->description); @@ -48,14 +49,16 @@ class Photo_Helper_Test extends Unit_Test_Case { public function create_conflicting_photo_test() { $rand = rand(); - $photo1 = photo::create(1, DOCROOT . "core/tests/test.jpg", "$rand.jpg", $rand, $rand); - $photo2 = photo::create(1, DOCROOT . "core/tests/test.jpg", "$rand.jpg", $rand, $rand); + $root = ORM::factory("item", 1); + $photo1 = photo::create($root, DOCROOT . "core/tests/test.jpg", "$rand.jpg", $rand, $rand); + $photo2 = photo::create($root, DOCROOT . "core/tests/test.jpg", "$rand.jpg", $rand, $rand); $this->assert_true($photo1->name != $photo2->name); } public function create_photo_with_no_extension_test() { + $root = ORM::factory("item", 1); try { - photo::create(1, "/tmp", "name", "title", "description"); + photo::create($root, "/tmp", "name", "title", "description"); $this->assert_false("should fail with an exception"); } catch (Exception $e) { // pass @@ -64,14 +67,16 @@ class Photo_Helper_Test extends Unit_Test_Case { public function thumb_url_test() { $rand = rand(); - $photo = photo::create(1, DOCROOT . "core/tests/test.jpg", "$rand.jpg", $rand, $rand); + $root = ORM::factory("item", 1); + $photo = photo::create($root, DOCROOT . "core/tests/test.jpg", "$rand.jpg", $rand, $rand); $this->assert_equal("http://./var/thumbs/{$rand}.jpg", $photo->thumb_url()); } public function resize_url_test() { $rand = rand(); - $album = album::create(1, $rand, $rand, $rand); - $photo = photo::create($album->id, DOCROOT . "core/tests/test.jpg", "$rand.jpg", $rand, $rand); + $root = ORM::factory("item", 1); + $album = album::create($root, $rand, $rand, $rand); + $photo = photo::create($album, DOCROOT . "core/tests/test.jpg", "$rand.jpg", $rand, $rand); $this->assert_equal("http://./var/resizes/{$rand}/{$rand}.jpg", $photo->resize_url()); } diff --git a/core/tests/Var_Test.php b/core/tests/Var_Test.php index 272a39fa..e186a7c2 100644 --- a/core/tests/Var_Test.php +++ b/core/tests/Var_Test.php @@ -24,14 +24,5 @@ class Var_Test extends Unit_Test_Case { module::set_var("core", "Parameter", "updated value"); $this->assert_equal("updated value", module::get_var("core", "Parameter")); - - module::set_var("core", "Parameter2", "new parameter"); - $core = module::get("core"); - - $params = $core->vars->select_list("name", "value"); - $this->assert_false(empty($params["Parameter"])); - $this->assert_equal("updated value", $params["Parameter"]); - $this->assert_false(empty($params["Parameter2"])); - $this->assert_equal("new parameter", $params["Parameter2"]); } }
\ No newline at end of file |