|
@@ 308-333 (lines=26) @@
|
| 305 |
|
* @covers \eZ\Publish\Core\Repository\Helper\LimitationService::validateLimitation |
| 306 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
| 307 |
|
*/ |
| 308 |
|
public function testAssignRoleToUserThrowsBadStateException() |
| 309 |
|
{ |
| 310 |
|
$repository = $this->getRepositoryMock(); |
| 311 |
|
$roleServiceMock = $this->getPartlyMockedRoleService(); |
| 312 |
|
/** @var \eZ\Publish\API\Repository\Values\User\Role $roleMock */ |
| 313 |
|
$roleMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\Role'); |
| 314 |
|
/** @var \eZ\Publish\API\Repository\Values\User\User $userMock */ |
| 315 |
|
$userMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\User'); |
| 316 |
|
$limitationMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\Limitation\\RoleLimitation'); |
| 317 |
|
|
| 318 |
|
$limitationMock->expects($this->once()) |
| 319 |
|
->method('getIdentifier') |
| 320 |
|
->will($this->returnValue('testIdentifier')); |
| 321 |
|
|
| 322 |
|
$repository->expects($this->once()) |
| 323 |
|
->method('canUser') |
| 324 |
|
->with( |
| 325 |
|
$this->equalTo('role'), |
| 326 |
|
$this->equalTo('assign'), |
| 327 |
|
$this->equalTo($userMock), |
| 328 |
|
$this->equalTo($roleMock) |
| 329 |
|
)->will($this->returnValue(true)); |
| 330 |
|
|
| 331 |
|
/* @var \eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $limitationMock */ |
| 332 |
|
$roleServiceMock->assignRoleToUser($roleMock, $userMock, $limitationMock); |
| 333 |
|
} |
| 334 |
|
|
| 335 |
|
/** |
| 336 |
|
* Test for the assignRoleToUser() method. |
|
@@ 632-657 (lines=26) @@
|
| 629 |
|
* @covers \eZ\Publish\Core\Repository\Helper\LimitationService::validateLimitation |
| 630 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
| 631 |
|
*/ |
| 632 |
|
public function testAssignRoleGroupToUserThrowsBadStateException() |
| 633 |
|
{ |
| 634 |
|
$repository = $this->getRepositoryMock(); |
| 635 |
|
$roleServiceMock = $this->getPartlyMockedRoleService(); |
| 636 |
|
/** @var \eZ\Publish\API\Repository\Values\User\Role $roleMock */ |
| 637 |
|
$roleMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\Role'); |
| 638 |
|
/** @var \eZ\Publish\API\Repository\Values\User\UserGroup $userGroupMock */ |
| 639 |
|
$userGroupMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\UserGroup'); |
| 640 |
|
$limitationMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\Limitation\\RoleLimitation'); |
| 641 |
|
|
| 642 |
|
$limitationMock->expects($this->once()) |
| 643 |
|
->method('getIdentifier') |
| 644 |
|
->will($this->returnValue('testIdentifier')); |
| 645 |
|
|
| 646 |
|
$repository->expects($this->once()) |
| 647 |
|
->method('canUser') |
| 648 |
|
->with( |
| 649 |
|
$this->equalTo('role'), |
| 650 |
|
$this->equalTo('assign'), |
| 651 |
|
$this->equalTo($userGroupMock), |
| 652 |
|
$this->equalTo($roleMock) |
| 653 |
|
)->will($this->returnValue(true)); |
| 654 |
|
|
| 655 |
|
/* @var \eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $limitationMock */ |
| 656 |
|
$roleServiceMock->assignRoleToUserGroup($roleMock, $userGroupMock, $limitationMock); |
| 657 |
|
} |
| 658 |
|
|
| 659 |
|
/** |
| 660 |
|
* Test for the assignRoleToUserGroup() method. |