Commit ac2e876f23dd8e96131c95b1a29d12550a481e5f

Authored by Conrad Vermeulen
1 parent 5bf097a0

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@9699 c91229c…

…3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 28 additions and 6 deletions
tests/api/testAcl.php
... ... @@ -123,30 +123,47 @@ class APIAclTestCase extends KTUnitTestCase {
123 123 function testRoleAllocation()
124 124 {
125 125 $root = $this->ktapi->get_root_folder();
  126 + $folder = $this->ktapi->get_folder_by_name('/test123');
126 127  
127   - $allocation = KTAPI_RoleAllocation::getAllocation($this->ktapi, $root);
  128 + $allocation = KTAPI_RoleAllocation::getAllocation($this->ktapi, $folder);
128 129  
  130 + $role2 = KTAPI_Role::getByName('Reviewer');
129 131 $role = KTAPI_Role::getByName('Publisher');
130 132 $user = KTAPI_User::getByUsername('admin');
131 133 $user2 = KTAPI_User::getByUsername('anonymous');
132 134 $group = KTAPI_Group::getByName('System Administrators');
133 135  
  136 +// $this->assertFalse($allocation->doesRoleHaveMember($role, $user));
  137 +// $this->assertTrue($allocation->doesRoleHaveMember($role2, $user));
  138 +
  139 +
  140 +
  141 + $allocation->add($role2, $user);
134 142 $allocation->add($role, $user);
135   - $allocation->add($role, $user2);
  143 + $allocation->add($role, $group);
  144 + $allocation->save();
  145 +/* $allocation->add($role, $user2);
136 146 $allocation->add($role, $user2); // yup. this is a dup. just to test.
137 147 $allocation->add($role, $group);
138 148  
139   - $this->assertTrue($allocation->doesRoleHasMember($role, $user));
  149 + $this->assertTrue($allocation->doesRoleHaveMember($role, $user));
140 150  
141 151 $allocation->remove($role, $user);
142 152  
143   - $this->assertFalse($allocation->doesRoleHasMember($role, $user));
  153 + $this->assertFalse($allocation->doesRoleHaveMember($role, $user));
144 154  
145 155 $allocation->remove($role, $user2);
146 156  
147   - $this->assertFalse($allocation->doesRoleHasMember($role, $user2));
  157 + $this->assertFalse($allocation->doesRoleHaveMember($role, $user2));
148 158  
149 159 $allocation->save();
  160 +
  161 + // now, just overwrite the allocation variable, and check that the assertions still hold.
  162 +
  163 + $allocation = KTAPI_RoleAllocation::getAllocation($this->ktapi, $root);
  164 + $this->assertFalse($allocation->doesRoleHaveMember($role, $user));
  165 + $this->assertFalse($allocation->doesRoleHaveMember($role, $user2));*/
  166 +
150 167 }
151 168  
152 169 /**
... ... @@ -156,6 +173,7 @@ class APIAclTestCase extends KTUnitTestCase {
156 173 function testPermissionAllocation()
157 174 {
158 175 $root = $this->ktapi->get_root_folder();
  176 + $folder = $this->ktapi->get_folder_by_name('/test123');
159 177  
160 178 $allocation = KTAPI_PermissionAllocation::getAllocation($this->ktapi, $root);
161 179  
... ... @@ -163,10 +181,14 @@ class APIAclTestCase extends KTUnitTestCase {
163 181 $user = KTAPI_User::getByUsername('anonymous');
164 182 $read = KTAPI_Permission::getByNamespace('ktcore.permissions.read');
165 183 $write = KTAPI_Permission::getByNamespace('ktcore.permissions.write');
  184 + $addFolder = KTAPI_Permission::getByNamespace('ktcore.permissions.addFolder');
  185 + $security = KTAPI_Permission::getByNamespace('ktcore.permissions.security');
166 186  
167 187 $allocation->add($user, $read);
168 188 $allocation->add($user, $write);
169   - $allocation->delete($group, $write);
  189 + $allocation->add($user, $addFolder);
  190 + $allocation->add($user, $security);
  191 + $allocation->remove($group, $write);
170 192  
171 193 $allocation->save();
172 194  
... ...