@@ 57-71 (lines=15) @@ | ||
54 | $this->assertTrue($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 | { |
|
@@ 360-374 (lines=15) @@ | ||
357 | $this->assertFalse($this->parameterResolver->resolveHateoas()); |
|
358 | } |
|
359 | ||
360 | public function testResolveHateoasExplicit() |
|
361 | { |
|
362 | $this->requestStack |
|
363 | ->expects($this->once()) |
|
364 | ->method('getMasterRequest') |
|
365 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
366 | ||
367 | $request->attributes |
|
368 | ->expects($this->once()) |
|
369 | ->method('get') |
|
370 | ->with($this->identicalTo('_lug_hateoas'), $this->identicalTo(false)) |
|
371 | ->will($this->returnValue(true)); |
|
372 | ||
373 | $this->assertTrue($this->parameterResolver->resolveHateoas()); |
|
374 | } |
|
375 | ||
376 | public function testResolveLocationRoute() |
|
377 | { |
|
@@ 776-790 (lines=15) @@ | ||
773 | $this->assertFalse($this->parameterResolver->resolveRedirectRouteParametersForward()); |
|
774 | } |
|
775 | ||
776 | public function testResolveRedirectRouteParametersForwardExplicit() |
|
777 | { |
|
778 | $this->requestStack |
|
779 | ->expects($this->once()) |
|
780 | ->method('getMasterRequest') |
|
781 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
782 | ||
783 | $request->attributes |
|
784 | ->expects($this->once()) |
|
785 | ->method('get') |
|
786 | ->with($this->identicalTo('_lug_redirect_route_parameters_forward'), $this->identicalTo(false)) |
|
787 | ->will($this->returnValue(true)); |
|
788 | ||
789 | $this->assertTrue($this->parameterResolver->resolveRedirectRouteParametersForward()); |
|
790 | } |
|
791 | ||
792 | public function testResolveRepositoryMethodWithoutRequest() |
|
793 | { |
|
@@ 877-891 (lines=15) @@ | ||
874 | $this->assertTrue($this->parameterResolver->resolveSerializerNull()); |
|
875 | } |
|
876 | ||
877 | public function testResolveSerializerNullDefault() |
|
878 | { |
|
879 | $this->requestStack |
|
880 | ->expects($this->once()) |
|
881 | ->method('getMasterRequest') |
|
882 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
883 | ||
884 | $request->attributes |
|
885 | ->expects($this->once()) |
|
886 | ->method('get') |
|
887 | ->with($this->identicalTo('_lug_serializer_null'), $this->identicalTo($null = true)) |
|
888 | ->will($this->returnValue($null)); |
|
889 | ||
890 | $this->assertTrue($this->parameterResolver->resolveSerializerNull()); |
|
891 | } |
|
892 | ||
893 | public function testResolveSerializerNullExplicit() |
|
894 | { |
|
@@ 1222-1236 (lines=15) @@ | ||
1219 | $this->assertFalse($this->parameterResolver->resolveVoter()); |
|
1220 | } |
|
1221 | ||
1222 | public function testResolveVoterExplicit() |
|
1223 | { |
|
1224 | $this->requestStack |
|
1225 | ->expects($this->once()) |
|
1226 | ->method('getMasterRequest') |
|
1227 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
1228 | ||
1229 | $request->attributes |
|
1230 | ->expects($this->once()) |
|
1231 | ->method('get') |
|
1232 | ->with($this->identicalTo('_lug_voter'), $this->identicalTo(false)) |
|
1233 | ->will($this->returnValue(true)); |
|
1234 | ||
1235 | $this->assertTrue($this->parameterResolver->resolveVoter()); |
|
1236 | } |
|
1237 | ||
1238 | /** |
|
1239 | * @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 |