123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- class GroupsWriteAccessTest extends ElggCoreUnitTest {
-
- protected $group;
-
- protected $user;
-
- public function setUp() {
- $this->group = new ElggGroup();
- $this->group->membership = ACCESS_PUBLIC;
- $this->group->access_id = ACCESS_PUBLIC;
- $this->group->save();
- $this->user = new ElggUser();
- $this->user->username = 'test_user_' . rand();
- $this->user->save();
- }
-
- public function testWriteAccessArray() {
- $membersonly = ElggGroup::CONTENT_ACCESS_MODE_MEMBERS_ONLY;
- $unrestricted = ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED;
- $original_page_owner = elgg_get_page_owner_entity();
- elgg_set_page_owner_guid($this->group->guid);
- $ia = elgg_set_ignore_access(false);
-
-
- $this->group->setContentAccessMode($membersonly);
- $write_access = get_write_access_array($this->user->guid, $this->group->site_guid, true);
- $this->assertFalse(array_key_exists($this->group->group_acl, $write_access));
-
- $this->group->setContentAccessMode($unrestricted);
- $write_access = get_write_access_array($this->user->guid, $this->group->site_guid, true);
- $this->assertFalse(array_key_exists($this->group->group_acl, $write_access));
-
- $this->group->join($this->user);
-
- $this->group->setContentAccessMode($membersonly);
- $write_access = get_write_access_array($this->user->guid, $this->group->site_guid, true);
- $this->assertTrue(array_key_exists($this->group->group_acl, $write_access));
-
- $this->group->setContentAccessMode($unrestricted);
- $write_access = get_write_access_array($this->user->guid, $this->group->site_guid, true);
- $this->assertTrue(array_key_exists($this->group->group_acl, $write_access));
- elgg_set_ignore_access($ia);
- $this->group->leave($this->user);
- $original_page_owner_guid = (elgg_instanceof($original_page_owner)) ? $original_page_owner->guid : 0;
- elgg_set_page_owner_guid($original_page_owner_guid);
- }
-
- public function tearDown() {
- $this->group->delete();
- $this->user->delete();
- }
- }
|