| @@ 57-71 (lines=15) @@ | ||
| 54 | $this->assertFalse($this->parameterResolver->resolveApi()); |
|
| 55 | } |
|
| 56 | ||
| 57 | public function testResolveApiWihApiRequest() |
|
| 58 | { |
|
| 59 | $this->requestStack |
|
| 60 | ->expects($this->exactly(2)) |
|
| 61 | ->method('getMasterRequest') |
|
| 62 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
| 63 | ||
| 64 | $request->attributes |
|
| 65 | ->expects($this->once()) |
|
| 66 | ->method('get') |
|
| 67 | ->with($this->identicalTo('_lug_api'), $this->identicalTo(false)) |
|
| 68 | ->will($this->returnValue(true)); |
|
| 69 | ||
| 70 | $this->assertTrue($this->parameterResolver->resolveApi()); |
|
| 71 | } |
|
| 72 | ||
| 73 | public function testResolveApiWithHtmlRequest() |
|
| 74 | { |
|
| @@ 394-408 (lines=15) @@ | ||
| 391 | $this->assertFalse($this->parameterResolver->resolveHateoas()); |
|
| 392 | } |
|
| 393 | ||
| 394 | public function testResolveHateoasExplicit() |
|
| 395 | { |
|
| 396 | $this->requestStack |
|
| 397 | ->expects($this->once()) |
|
| 398 | ->method('getMasterRequest') |
|
| 399 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
| 400 | ||
| 401 | $request->attributes |
|
| 402 | ->expects($this->once()) |
|
| 403 | ->method('get') |
|
| 404 | ->with($this->identicalTo('_lug_hateoas'), $this->identicalTo(false)) |
|
| 405 | ->will($this->returnValue(true)); |
|
| 406 | ||
| 407 | $this->assertTrue($this->parameterResolver->resolveHateoas()); |
|
| 408 | } |
|
| 409 | ||
| 410 | public function testResolveLocationRoute() |
|
| 411 | { |
|
| @@ 732-746 (lines=15) @@ | ||
| 729 | $this->assertFalse($this->parameterResolver->resolveRedirectRouteParametersForward()); |
|
| 730 | } |
|
| 731 | ||
| 732 | public function testResolveRedirectRouteParametersForwardExplicit() |
|
| 733 | { |
|
| 734 | $this->requestStack |
|
| 735 | ->expects($this->once()) |
|
| 736 | ->method('getMasterRequest') |
|
| 737 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
| 738 | ||
| 739 | $request->attributes |
|
| 740 | ->expects($this->once()) |
|
| 741 | ->method('get') |
|
| 742 | ->with($this->identicalTo('_lug_redirect_route_parameters_forward'), $this->identicalTo(false)) |
|
| 743 | ->will($this->returnValue(true)); |
|
| 744 | ||
| 745 | $this->assertTrue($this->parameterResolver->resolveRedirectRouteParametersForward()); |
|
| 746 | } |
|
| 747 | ||
| 748 | public function testResolveRepositoryMethodWithoutRequest() |
|
| 749 | { |
|
| @@ 833-847 (lines=15) @@ | ||
| 830 | $this->assertTrue($this->parameterResolver->resolveSerializerNull()); |
|
| 831 | } |
|
| 832 | ||
| 833 | public function testResolveSerializerNullDefault() |
|
| 834 | { |
|
| 835 | $this->requestStack |
|
| 836 | ->expects($this->once()) |
|
| 837 | ->method('getMasterRequest') |
|
| 838 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
| 839 | ||
| 840 | $request->attributes |
|
| 841 | ->expects($this->once()) |
|
| 842 | ->method('get') |
|
| 843 | ->with($this->identicalTo('_lug_serializer_null'), $this->identicalTo($null = true)) |
|
| 844 | ->will($this->returnValue($null)); |
|
| 845 | ||
| 846 | $this->assertTrue($this->parameterResolver->resolveSerializerNull()); |
|
| 847 | } |
|
| 848 | ||
| 849 | public function testResolveSerializerNullExplicit() |
|
| 850 | { |
|
| @@ 1178-1192 (lines=15) @@ | ||
| 1175 | $this->assertFalse($this->parameterResolver->resolveVoter()); |
|
| 1176 | } |
|
| 1177 | ||
| 1178 | public function testResolveVoterExplicit() |
|
| 1179 | { |
|
| 1180 | $this->requestStack |
|
| 1181 | ->expects($this->once()) |
|
| 1182 | ->method('getMasterRequest') |
|
| 1183 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
| 1184 | ||
| 1185 | $request->attributes |
|
| 1186 | ->expects($this->once()) |
|
| 1187 | ->method('get') |
|
| 1188 | ->with($this->identicalTo('_lug_voter'), $this->identicalTo(false)) |
|
| 1189 | ->will($this->returnValue(true)); |
|
| 1190 | ||
| 1191 | $this->assertTrue($this->parameterResolver->resolveVoter()); |
|
| 1192 | } |
|
| 1193 | ||
| 1194 | /** |
|
| 1195 | * @return \PHPUnit_Framework_MockObject_MockObject|RequestStack |
|
| @@ 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 |
|