| @@ 268-281 (lines=14) @@ | ||
| 265 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Handler::delete |
|
| 266 | * @expectedException LogicException |
|
| 267 | */ |
|
| 268 | public function testDeleteFail() |
|
| 269 | { |
|
| 270 | $handler = $this->getLanguageHandler(); |
|
| 271 | $gatewayMock = $this->getGatewayMock(); |
|
| 272 | ||
| 273 | $gatewayMock->expects($this->once()) |
|
| 274 | ->method('canDeleteLanguage') |
|
| 275 | ->with($this->equalTo(2)) |
|
| 276 | ->will($this->returnValue(false)); |
|
| 277 | $gatewayMock->expects($this->never()) |
|
| 278 | ->method('deleteLanguage'); |
|
| 279 | ||
| 280 | $result = $handler->delete(2); |
|
| 281 | } |
|
| 282 | ||
| 283 | /** |
|
| 284 | * Returns the language handler to test. |
|
| @@ 248-263 (lines=16) @@ | ||
| 245 | * @covers eZ\Publish\Core\Persistence\Legacy\Content\Section\Handler::delete |
|
| 246 | * @expectedException RuntimeException |
|
| 247 | */ |
|
| 248 | public function testDeleteFailure() |
|
| 249 | { |
|
| 250 | $handler = $this->getSectionHandler(); |
|
| 251 | ||
| 252 | $gatewayMock = $this->getGatewayMock(); |
|
| 253 | ||
| 254 | $gatewayMock->expects($this->once()) |
|
| 255 | ->method('countContentObjectsInSection') |
|
| 256 | ->with($this->equalTo(23)) |
|
| 257 | ->will($this->returnValue(2)); |
|
| 258 | ||
| 259 | $gatewayMock->expects($this->never()) |
|
| 260 | ->method('deleteSection'); |
|
| 261 | ||
| 262 | $result = $handler->delete(23); |
|
| 263 | } |
|
| 264 | ||
| 265 | /** |
|
| 266 | * @covers eZ\Publish\Core\Persistence\Legacy\Content\Section\Handler::assign |
|
| @@ 893-908 (lines=16) @@ | ||
| 890 | * @covers \eZ\Publish\Core\Repository\RoleService::deletePolicy |
|
| 891 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 892 | */ |
|
| 893 | public function testDeletePolicyThrowsUnauthorizedException() |
|
| 894 | { |
|
| 895 | $repository = $this->getRepositoryMock(); |
|
| 896 | $roleServiceMock = $this->getPartlyMockedRoleService(); |
|
| 897 | $policyMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\Policy'); |
|
| 898 | ||
| 899 | $repository->expects($this->once()) |
|
| 900 | ->method('hasAccess') |
|
| 901 | ->with( |
|
| 902 | $this->equalTo('role'), |
|
| 903 | $this->equalTo('update') |
|
| 904 | )->will($this->returnValue(false)); |
|
| 905 | ||
| 906 | /* @var \eZ\Publish\API\Repository\Values\User\Policy $policyMock */ |
|
| 907 | $roleServiceMock->deletePolicy($policyMock); |
|
| 908 | } |
|
| 909 | ||
| 910 | /** |
|
| 911 | * Test for the deletePolicy() method. |
|
| @@ 1006-1023 (lines=18) @@ | ||
| 1003 | * @covers \eZ\Publish\Core\Repository\RoleService::removePolicy |
|
| 1004 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 1005 | */ |
|
| 1006 | public function testRemovePolicyThrowsUnauthorizedException() |
|
| 1007 | { |
|
| 1008 | $repository = $this->getRepositoryMock(); |
|
| 1009 | $roleServiceMock = $this->getPartlyMockedRoleService(); |
|
| 1010 | $roleMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\Role'); |
|
| 1011 | $policyMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\Policy'); |
|
| 1012 | ||
| 1013 | $repository->expects($this->once()) |
|
| 1014 | ->method('hasAccess') |
|
| 1015 | ->with( |
|
| 1016 | $this->equalTo('role'), |
|
| 1017 | $this->equalTo('update') |
|
| 1018 | )->will($this->returnValue(false)); |
|
| 1019 | ||
| 1020 | /* @var \eZ\Publish\API\Repository\Values\User\Role $roleMock */ |
|
| 1021 | /* @var \eZ\Publish\API\Repository\Values\User\Policy $policyMock */ |
|
| 1022 | $roleServiceMock->removePolicy($roleMock, $policyMock); |
|
| 1023 | } |
|
| 1024 | ||
| 1025 | /** |
|
| 1026 | * Test for the removePolicy() method. |
|
| @@ 387-400 (lines=14) @@ | ||
| 384 | * |
|
| 385 | * @dataProvider providerForTestGetPermissionsCriterionBooleanPermissionSets |
|
| 386 | */ |
|
| 387 | public function testGetPermissionsCriterionBooleanPermissionSets($permissionSets) |
|
| 388 | { |
|
| 389 | $repositoryMock = $this->getRepositoryMock(); |
|
| 390 | $repositoryMock |
|
| 391 | ->expects($this->once()) |
|
| 392 | ->method('hasAccess') |
|
| 393 | ->with($this->equalTo('testModule'), $this->equalTo('testFunction')) |
|
| 394 | ->will($this->returnValue($permissionSets)); |
|
| 395 | $handler = new PermissionsCriterionHandler($this->getRepositoryMock()); |
|
| 396 | ||
| 397 | $permissionsCriterion = $handler->getPermissionsCriterion('testModule', 'testFunction'); |
|
| 398 | ||
| 399 | $this->assertEquals($permissionSets, $permissionsCriterion); |
|
| 400 | } |
|
| 401 | ||
| 402 | /** |
|
| 403 | * Returns the PermissionsCriterionHandler to test with $methods mocked. |
|