| @@ 386-399 (lines=14) @@ | ||
| 383 | * |
|
| 384 | * @dataProvider providerForTestGetPermissionsCriterionBooleanPermissionSets |
|
| 385 | */ |
|
| 386 | public function testGetPermissionsCriterionBooleanPermissionSets($permissionSets) |
|
| 387 | { |
|
| 388 | $permissionServiceMock = $this->getPermissionServiceMock(['hasAccess']); |
|
| 389 | $permissionServiceMock |
|
| 390 | ->expects($this->once()) |
|
| 391 | ->method('hasAccess') |
|
| 392 | ->with($this->equalTo('testModule'), $this->equalTo('testFunction')) |
|
| 393 | ->will($this->returnValue($permissionSets)); |
|
| 394 | $handler = $this->getPermissionsCriterionHandlerMock(null); |
|
| 395 | ||
| 396 | $permissionsCriterion = $handler->getPermissionsCriterion('testModule', 'testFunction'); |
|
| 397 | ||
| 398 | $this->assertEquals($permissionSets, $permissionsCriterion); |
|
| 399 | } |
|
| 400 | ||
| 401 | /** |
|
| 402 | * Returns the PermissionsCriterionHandler to test with $methods mocked. |
|
| @@ 611-628 (lines=18) @@ | ||
| 608 | * |
|
| 609 | * @dataProvider providerForTestCanUserSimple |
|
| 610 | */ |
|
| 611 | public function testCanUserSimple($permissionSets, $result) |
|
| 612 | { |
|
| 613 | $permissionServiceMock = $this->getPermissionServiceMock(['hasAccess']); |
|
| 614 | ||
| 615 | $permissionServiceMock |
|
| 616 | ->expects($this->once()) |
|
| 617 | ->method('hasAccess') |
|
| 618 | ->with($this->equalTo('test-module'), $this->equalTo('test-function')) |
|
| 619 | ->will($this->returnValue($permissionSets)); |
|
| 620 | ||
| 621 | /** @var $valueObject \eZ\Publish\API\Repository\Values\ValueObject */ |
|
| 622 | $valueObject = $this->getMockForAbstractClass('eZ\\Publish\\API\\Repository\\Values\\ValueObject'); |
|
| 623 | ||
| 624 | self::assertEquals( |
|
| 625 | $result, |
|
| 626 | $permissionServiceMock->canUser('test-module', 'test-function', $valueObject, $valueObject) |
|
| 627 | ); |
|
| 628 | } |
|
| 629 | ||
| 630 | /** |
|
| 631 | * Test for the canUser() method. |
|