| @@ 69-86 (lines=18) @@ | ||
| 66 | $this->assertTrue($this->securityChecker->isGranted('show', $this->createStdClassMock())); |
|
| 67 | } |
|
| 68 | ||
| 69 | public function testIsGrantedWithVoter() |
|
| 70 | { |
|
| 71 | $this->parameterResolver |
|
| 72 | ->expects($this->once()) |
|
| 73 | ->method('resolveVoter') |
|
| 74 | ->will($this->returnValue(true)); |
|
| 75 | ||
| 76 | $this->authorizationChecker |
|
| 77 | ->expects($this->once()) |
|
| 78 | ->method('isGranted') |
|
| 79 | ->with( |
|
| 80 | $this->identicalTo('lug.'.($action = 'show')), |
|
| 81 | $this->identicalTo($object = $this->createStdClassMock()) |
|
| 82 | ) |
|
| 83 | ->will($this->returnValue(true)); |
|
| 84 | ||
| 85 | $this->assertTrue($this->securityChecker->isGranted($action, $object)); |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * @return \PHPUnit_Framework_MockObject_MockObject|AuthorizationCheckerInterface |
|
| @@ 58-72 (lines=15) @@ | ||
| 55 | $this->assertFalse($this->parameterResolver->resolveApi()); |
|
| 56 | } |
|
| 57 | ||
| 58 | public function testResolveApiWihApiRequest() |
|
| 59 | { |
|
| 60 | $this->requestStack |
|
| 61 | ->expects($this->exactly(2)) |
|
| 62 | ->method('getMasterRequest') |
|
| 63 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
| 64 | ||
| 65 | $request->attributes |
|
| 66 | ->expects($this->once()) |
|
| 67 | ->method('get') |
|
| 68 | ->with($this->identicalTo('_lug_api'), $this->identicalTo(false)) |
|
| 69 | ->will($this->returnValue(true)); |
|
| 70 | ||
| 71 | $this->assertTrue($this->parameterResolver->resolveApi()); |
|
| 72 | } |
|
| 73 | ||
| 74 | public function testResolveApiWithHtmlRequest() |
|
| 75 | { |
|
| @@ 395-409 (lines=15) @@ | ||
| 392 | $this->assertFalse($this->parameterResolver->resolveHateoas()); |
|
| 393 | } |
|
| 394 | ||
| 395 | public function testResolveHateoasExplicit() |
|
| 396 | { |
|
| 397 | $this->requestStack |
|
| 398 | ->expects($this->once()) |
|
| 399 | ->method('getMasterRequest') |
|
| 400 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
| 401 | ||
| 402 | $request->attributes |
|
| 403 | ->expects($this->once()) |
|
| 404 | ->method('get') |
|
| 405 | ->with($this->identicalTo('_lug_hateoas'), $this->identicalTo(false)) |
|
| 406 | ->will($this->returnValue(true)); |
|
| 407 | ||
| 408 | $this->assertTrue($this->parameterResolver->resolveHateoas()); |
|
| 409 | } |
|
| 410 | ||
| 411 | public function testResolveLocationRoute() |
|
| 412 | { |
|
| @@ 733-747 (lines=15) @@ | ||
| 730 | $this->assertFalse($this->parameterResolver->resolveRedirectRouteParametersForward()); |
|
| 731 | } |
|
| 732 | ||
| 733 | public function testResolveRedirectRouteParametersForwardExplicit() |
|
| 734 | { |
|
| 735 | $this->requestStack |
|
| 736 | ->expects($this->once()) |
|
| 737 | ->method('getMasterRequest') |
|
| 738 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
| 739 | ||
| 740 | $request->attributes |
|
| 741 | ->expects($this->once()) |
|
| 742 | ->method('get') |
|
| 743 | ->with($this->identicalTo('_lug_redirect_route_parameters_forward'), $this->identicalTo(false)) |
|
| 744 | ->will($this->returnValue(true)); |
|
| 745 | ||
| 746 | $this->assertTrue($this->parameterResolver->resolveRedirectRouteParametersForward()); |
|
| 747 | } |
|
| 748 | ||
| 749 | public function testResolveRepositoryMethodWithoutRequest() |
|
| 750 | { |
|
| @@ 828-842 (lines=15) @@ | ||
| 825 | $this->assertTrue($this->parameterResolver->resolveSerializerNull()); |
|
| 826 | } |
|
| 827 | ||
| 828 | public function testResolveSerializerNullDefault() |
|
| 829 | { |
|
| 830 | $this->requestStack |
|
| 831 | ->expects($this->once()) |
|
| 832 | ->method('getMasterRequest') |
|
| 833 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
| 834 | ||
| 835 | $request->attributes |
|
| 836 | ->expects($this->once()) |
|
| 837 | ->method('get') |
|
| 838 | ->with($this->identicalTo('_lug_serializer_null'), $this->identicalTo($null = true)) |
|
| 839 | ->will($this->returnValue($null)); |
|
| 840 | ||
| 841 | $this->assertTrue($this->parameterResolver->resolveSerializerNull()); |
|
| 842 | } |
|
| 843 | ||
| 844 | public function testResolveSerializerNullExplicit() |
|
| 845 | { |
|
| @@ 1163-1177 (lines=15) @@ | ||
| 1160 | $this->assertFalse($this->parameterResolver->resolveVoter()); |
|
| 1161 | } |
|
| 1162 | ||
| 1163 | public function testResolveVoterExplicit() |
|
| 1164 | { |
|
| 1165 | $this->requestStack |
|
| 1166 | ->expects($this->once()) |
|
| 1167 | ->method('getMasterRequest') |
|
| 1168 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
| 1169 | ||
| 1170 | $request->attributes |
|
| 1171 | ->expects($this->once()) |
|
| 1172 | ->method('get') |
|
| 1173 | ->with($this->identicalTo('_lug_voter'), $this->identicalTo(false)) |
|
| 1174 | ->will($this->returnValue(true)); |
|
| 1175 | ||
| 1176 | $this->assertTrue($this->parameterResolver->resolveVoter()); |
|
| 1177 | } |
|
| 1178 | ||
| 1179 | /** |
|
| 1180 | * @return \PHPUnit_Framework_MockObject_MockObject|RequestStack |
|