diff options
author | Chad Kieffer <ckieffer@gmail.com> | 2009-07-25 09:25:31 -0600 |
---|---|---|
committer | Chad Kieffer <ckieffer@gmail.com> | 2009-07-25 09:25:31 -0600 |
commit | eca46d76a7832f771d377edb3939ea1aded2fac9 (patch) | |
tree | d4f0323202c7eb6eab60ff6e14f9905b625e349b /modules/gallery/tests/Access_Helper_Test.php | |
parent | 63511316be51f193d37c4f3b9dd3455a9ab60de8 (diff) | |
parent | 50d6cc0150b930d79d3e8b90956ffa9655fcc9c5 (diff) |
Merge branch 'master' of git@github.com:gallery/gallery3
Diffstat (limited to 'modules/gallery/tests/Access_Helper_Test.php')
-rw-r--r-- | modules/gallery/tests/Access_Helper_Test.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php index 1352b493..59cec453 100644 --- a/modules/gallery/tests/Access_Helper_Test.php +++ b/modules/gallery/tests/Access_Helper_Test.php @@ -64,6 +64,43 @@ class Access_Helper_Test extends Unit_Test_Case { $this->assert_false(array_key_exists("access_test_{$group->id}", $fields)); } + public function user_can_access_test() { + $access_test = group::create("access_test"); + + $root = ORM::factory("item", 1); + access::allow($access_test, "view", $root); + + $item = album::create($root, rand(), "test album"); + + access::deny(group::everybody(), "view", $item); + access::deny(group::registered_users(), "view", $item); + + $user = user::create("access_test", "Access Test", ""); + foreach ($user->groups as $group) { + $user->remove($group); + } + $user->add($access_test); + $user->save(); + + $this->assert_true(access::user_can($user, "view", $item), "Should be able to view"); + } + + public function user_can_no_access_test() { + $root = ORM::factory("item", 1); + $item = album::create($root, rand(), "test album"); + + access::deny(group::everybody(), "view", $item); + access::deny(group::registered_users(), "view", $item); + + $user = user::create("access_test", "Access Test", ""); + foreach ($user->groups as $group) { + $user->remove($group); + } + $user->save(); + + $this->assert_false(access::user_can($user, "view", $item), "Should be unable to view"); + } + public function adding_and_removing_items_adds_ands_removes_rows_test() { $root = ORM::factory("item", 1); $item = album::create($root, rand(), "test album"); |