|
@@ 944-965 (lines=22) @@
|
| 941 |
|
* |
| 942 |
|
* @group permission-lookup |
| 943 |
|
*/ |
| 944 |
|
public function testLookupGrantedSimple() |
| 945 |
|
{ |
| 946 |
|
$module = 'module'; |
| 947 |
|
$function = 'function'; |
| 948 |
|
$limitations = []; |
| 949 |
|
$permissionResolver = $this->getPermissionResolverMock(['hasAccess']); |
| 950 |
|
|
| 951 |
|
$permissionResolver |
| 952 |
|
->expects($this->once()) |
| 953 |
|
->method('hasAccess') |
| 954 |
|
->with($module, $function) |
| 955 |
|
->willReturn(true); |
| 956 |
|
|
| 957 |
|
$permissionInfo = $permissionResolver->lookup($module, $function, $limitations); |
| 958 |
|
|
| 959 |
|
$this->assertInstanceOf( |
| 960 |
|
'eZ\Publish\API\Repository\Values\User\PermissionInfo', |
| 961 |
|
$permissionInfo |
| 962 |
|
); |
| 963 |
|
$this->assertSame(PermissionInfo::ACCESS_GRANTED, $permissionInfo->access); |
| 964 |
|
$this->assertEmpty($permissionInfo->limitationSets); |
| 965 |
|
} |
| 966 |
|
|
| 967 |
|
/** |
| 968 |
|
* Test for the lookup() method. |
|
@@ 972-993 (lines=22) @@
|
| 969 |
|
* |
| 970 |
|
* @group permission-lookup |
| 971 |
|
*/ |
| 972 |
|
public function testLookupDeniedSimple() |
| 973 |
|
{ |
| 974 |
|
$module = 'module'; |
| 975 |
|
$function = 'function'; |
| 976 |
|
$limitations = []; |
| 977 |
|
$permissionResolver = $this->getPermissionResolverMock(['hasAccess']); |
| 978 |
|
|
| 979 |
|
$permissionResolver |
| 980 |
|
->expects($this->once()) |
| 981 |
|
->method('hasAccess') |
| 982 |
|
->with($module, $function) |
| 983 |
|
->willReturn(false); |
| 984 |
|
|
| 985 |
|
$permissionInfo = $permissionResolver->lookup($module, $function, $limitations); |
| 986 |
|
|
| 987 |
|
$this->assertInstanceOf( |
| 988 |
|
'eZ\Publish\API\Repository\Values\User\PermissionInfo', |
| 989 |
|
$permissionInfo |
| 990 |
|
); |
| 991 |
|
$this->assertSame(PermissionInfo::ACCESS_DENIED, $permissionInfo->access); |
| 992 |
|
$this->assertEmpty($permissionInfo->limitationSets); |
| 993 |
|
} |
| 994 |
|
|
| 995 |
|
protected function assertLimitationTypeForLookup() |
| 996 |
|
{ |
|
@@ 1225-1246 (lines=22) @@
|
| 1222 |
|
* @param array $permissionSets |
| 1223 |
|
* @param array $limitations |
| 1224 |
|
*/ |
| 1225 |
|
public function testLookupGranted($permissionSets, $limitations) |
| 1226 |
|
{ |
| 1227 |
|
$module = 'module'; |
| 1228 |
|
$function = 'function'; |
| 1229 |
|
$permissionResolver = $this->getPermissionResolverMock(['hasAccess']); |
| 1230 |
|
$this->assertLimitationTypeForLookup(); |
| 1231 |
|
|
| 1232 |
|
$permissionResolver |
| 1233 |
|
->expects($this->once()) |
| 1234 |
|
->method('hasAccess') |
| 1235 |
|
->with($module, $function) |
| 1236 |
|
->willReturn($permissionSets); |
| 1237 |
|
|
| 1238 |
|
$permissionInfo = $permissionResolver->lookup($module, $function, $limitations); |
| 1239 |
|
|
| 1240 |
|
$this->assertInstanceOf( |
| 1241 |
|
'eZ\Publish\API\Repository\Values\User\PermissionInfo', |
| 1242 |
|
$permissionInfo |
| 1243 |
|
); |
| 1244 |
|
$this->assertSame(PermissionInfo::ACCESS_GRANTED, $permissionInfo->access); |
| 1245 |
|
$this->assertEmpty($permissionInfo->limitationSets); |
| 1246 |
|
} |
| 1247 |
|
|
| 1248 |
|
public function providerForTestLookupDenied() |
| 1249 |
|
{ |
|
@@ 1347-1368 (lines=22) @@
|
| 1344 |
|
* @param array $permissionSets |
| 1345 |
|
* @param array $limitations |
| 1346 |
|
*/ |
| 1347 |
|
public function testLookupDenied($permissionSets, $limitations) |
| 1348 |
|
{ |
| 1349 |
|
$module = 'module'; |
| 1350 |
|
$function = 'function'; |
| 1351 |
|
$permissionResolver = $this->getPermissionResolverMock(['hasAccess']); |
| 1352 |
|
$this->assertLimitationTypeForLookup(); |
| 1353 |
|
|
| 1354 |
|
$permissionResolver |
| 1355 |
|
->expects($this->once()) |
| 1356 |
|
->method('hasAccess') |
| 1357 |
|
->with($module, $function) |
| 1358 |
|
->willReturn($permissionSets); |
| 1359 |
|
|
| 1360 |
|
$permissionInfo = $permissionResolver->lookup($module, $function, $limitations); |
| 1361 |
|
|
| 1362 |
|
$this->assertInstanceOf( |
| 1363 |
|
'eZ\Publish\API\Repository\Values\User\PermissionInfo', |
| 1364 |
|
$permissionInfo |
| 1365 |
|
); |
| 1366 |
|
$this->assertSame(PermissionInfo::ACCESS_DENIED, $permissionInfo->access); |
| 1367 |
|
$this->assertEmpty($permissionInfo->limitationSets); |
| 1368 |
|
} |
| 1369 |
|
|
| 1370 |
|
public function providerForTestLookupLimited() |
| 1371 |
|
{ |