@@ 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 | { |
|
@@ 754-768 (lines=15) @@ | ||
751 | $this->assertFalse($this->parameterResolver->resolveRedirectRouteParametersForward()); |
|
752 | } |
|
753 | ||
754 | public function testResolveRedirectRouteParametersForwardExplicit() |
|
755 | { |
|
756 | $this->requestStack |
|
757 | ->expects($this->once()) |
|
758 | ->method('getMasterRequest') |
|
759 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
760 | ||
761 | $request->attributes |
|
762 | ->expects($this->once()) |
|
763 | ->method('get') |
|
764 | ->with($this->identicalTo('_lug_redirect_route_parameters_forward'), $this->identicalTo(false)) |
|
765 | ->will($this->returnValue(true)); |
|
766 | ||
767 | $this->assertTrue($this->parameterResolver->resolveRedirectRouteParametersForward()); |
|
768 | } |
|
769 | ||
770 | public function testResolveRepositoryMethodWithoutRequest() |
|
771 | { |
|
@@ 855-869 (lines=15) @@ | ||
852 | $this->assertTrue($this->parameterResolver->resolveSerializerNull()); |
|
853 | } |
|
854 | ||
855 | public function testResolveSerializerNullDefault() |
|
856 | { |
|
857 | $this->requestStack |
|
858 | ->expects($this->once()) |
|
859 | ->method('getMasterRequest') |
|
860 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
861 | ||
862 | $request->attributes |
|
863 | ->expects($this->once()) |
|
864 | ->method('get') |
|
865 | ->with($this->identicalTo('_lug_serializer_null'), $this->identicalTo($null = true)) |
|
866 | ->will($this->returnValue($null)); |
|
867 | ||
868 | $this->assertTrue($this->parameterResolver->resolveSerializerNull()); |
|
869 | } |
|
870 | ||
871 | public function testResolveSerializerNullExplicit() |
|
872 | { |
|
@@ 1200-1214 (lines=15) @@ | ||
1197 | $this->assertFalse($this->parameterResolver->resolveVoter()); |
|
1198 | } |
|
1199 | ||
1200 | public function testResolveVoterExplicit() |
|
1201 | { |
|
1202 | $this->requestStack |
|
1203 | ->expects($this->once()) |
|
1204 | ->method('getMasterRequest') |
|
1205 | ->will($this->returnValue($request = $this->createRequestMock())); |
|
1206 | ||
1207 | $request->attributes |
|
1208 | ->expects($this->once()) |
|
1209 | ->method('get') |
|
1210 | ->with($this->identicalTo('_lug_voter'), $this->identicalTo(false)) |
|
1211 | ->will($this->returnValue(true)); |
|
1212 | ||
1213 | $this->assertTrue($this->parameterResolver->resolveVoter()); |
|
1214 | } |
|
1215 | ||
1216 | /** |
|
1217 | * @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 |