|
@@ 259-299 (lines=41) @@
|
| 256 |
|
* @covers \eZ\Publish\Core\Repository\Helper\LimitationService::validateLimitation |
| 257 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\LimitationValidationException |
| 258 |
|
*/ |
| 259 |
|
public function testAssignRoleToUserThrowsLimitationValidationException() |
| 260 |
|
{ |
| 261 |
|
$limitationMock = $this->createMock('eZ\\Publish\\API\\Repository\\Values\\User\\Limitation\\RoleLimitation'); |
| 262 |
|
$limitationTypeMock = $this->createMock('eZ\\Publish\\SPI\\Limitation\\Type'); |
| 263 |
|
|
| 264 |
|
$limitationTypeMock->expects($this->once()) |
| 265 |
|
->method('acceptValue') |
| 266 |
|
->with($this->equalTo($limitationMock)); |
| 267 |
|
$limitationTypeMock->expects($this->once()) |
| 268 |
|
->method('validate') |
| 269 |
|
->with($this->equalTo($limitationMock)) |
| 270 |
|
->will($this->returnValue([42])); |
| 271 |
|
|
| 272 |
|
$limitationMock->expects($this->once()) |
| 273 |
|
->method('getIdentifier') |
| 274 |
|
->will($this->returnValue('testIdentifier')); |
| 275 |
|
|
| 276 |
|
$settings = [ |
| 277 |
|
'limitationTypes' => ['testIdentifier' => $limitationTypeMock], |
| 278 |
|
]; |
| 279 |
|
|
| 280 |
|
$roleServiceMock = $this->getPartlyMockedRoleService(null, $settings); |
| 281 |
|
|
| 282 |
|
$repository = $this->getRepositoryMock(); |
| 283 |
|
/** @var \eZ\Publish\API\Repository\Values\User\Role $roleMock */ |
| 284 |
|
$roleMock = $this->createMock('eZ\\Publish\\API\\Repository\\Values\\User\\Role'); |
| 285 |
|
/** @var \eZ\Publish\API\Repository\Values\User\User $userMock */ |
| 286 |
|
$userMock = $this->createMock('eZ\\Publish\\API\\Repository\\Values\\User\\User'); |
| 287 |
|
|
| 288 |
|
$repository->expects($this->once()) |
| 289 |
|
->method('canUser') |
| 290 |
|
->with( |
| 291 |
|
$this->equalTo('role'), |
| 292 |
|
$this->equalTo('assign'), |
| 293 |
|
$this->equalTo($userMock), |
| 294 |
|
$this->equalTo($roleMock) |
| 295 |
|
)->will($this->returnValue(true)); |
| 296 |
|
|
| 297 |
|
/* @var \eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $limitationMock */ |
| 298 |
|
$roleServiceMock->assignRoleToUser($roleMock, $userMock, $limitationMock); |
| 299 |
|
} |
| 300 |
|
|
| 301 |
|
/** |
| 302 |
|
* Test for the assignRoleToUser() method. |
|
@@ 583-623 (lines=41) @@
|
| 580 |
|
* @covers \eZ\Publish\Core\Repository\Helper\LimitationService::validateLimitation |
| 581 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\LimitationValidationException |
| 582 |
|
*/ |
| 583 |
|
public function testAssignRoleToUserGroupThrowsLimitationValidationException() |
| 584 |
|
{ |
| 585 |
|
$limitationMock = $this->createMock('eZ\\Publish\\API\\Repository\\Values\\User\\Limitation\\RoleLimitation'); |
| 586 |
|
$limitationTypeMock = $this->createMock('eZ\\Publish\\SPI\\Limitation\\Type'); |
| 587 |
|
|
| 588 |
|
$limitationTypeMock->expects($this->once()) |
| 589 |
|
->method('acceptValue') |
| 590 |
|
->with($this->equalTo($limitationMock)); |
| 591 |
|
$limitationTypeMock->expects($this->once()) |
| 592 |
|
->method('validate') |
| 593 |
|
->with($this->equalTo($limitationMock)) |
| 594 |
|
->will($this->returnValue([42])); |
| 595 |
|
|
| 596 |
|
$limitationMock->expects($this->once()) |
| 597 |
|
->method('getIdentifier') |
| 598 |
|
->will($this->returnValue('testIdentifier')); |
| 599 |
|
|
| 600 |
|
$settings = [ |
| 601 |
|
'limitationTypes' => ['testIdentifier' => $limitationTypeMock], |
| 602 |
|
]; |
| 603 |
|
|
| 604 |
|
$roleServiceMock = $this->getPartlyMockedRoleService(null, $settings); |
| 605 |
|
|
| 606 |
|
$repository = $this->getRepositoryMock(); |
| 607 |
|
/** @var \eZ\Publish\API\Repository\Values\User\Role $roleMock */ |
| 608 |
|
$roleMock = $this->createMock('eZ\\Publish\\API\\Repository\\Values\\User\\Role'); |
| 609 |
|
/** @var \eZ\Publish\API\Repository\Values\User\UserGroup $userGroupMock */ |
| 610 |
|
$userGroupMock = $this->createMock('eZ\\Publish\\API\\Repository\\Values\\User\\UserGroup'); |
| 611 |
|
|
| 612 |
|
$repository->expects($this->once()) |
| 613 |
|
->method('canUser') |
| 614 |
|
->with( |
| 615 |
|
$this->equalTo('role'), |
| 616 |
|
$this->equalTo('assign'), |
| 617 |
|
$this->equalTo($userGroupMock), |
| 618 |
|
$this->equalTo($roleMock) |
| 619 |
|
)->will($this->returnValue(true)); |
| 620 |
|
|
| 621 |
|
/* @var \eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $limitationMock */ |
| 622 |
|
$roleServiceMock->assignRoleToUserGroup($roleMock, $userGroupMock, $limitationMock); |
| 623 |
|
} |
| 624 |
|
|
| 625 |
|
/** |
| 626 |
|
* Test for the assignRoleToUserGroup() method. |