@@ 80-103 (lines=24) @@ | ||
77 | /** |
|
78 | * @test |
|
79 | */ |
|
80 | public function shouldCheckIfAccessIsGranted() |
|
81 | { |
|
82 | $this->expectException(AccessDeniedException::class); |
|
83 | ||
84 | /** @var Request $request */ |
|
85 | $request = $this->createMock(Request::class); |
|
86 | ||
87 | $this->controllerHelper->expects($this->once())->method('denyAccessUnlessGranted')->with( |
|
88 | $this->equalTo('some-attribute'), |
|
89 | $this->equalTo($request) |
|
90 | )->will($this->returnCallback( |
|
91 | function () { |
|
92 | throw new AccessDeniedException('Lorem ipsum!'); |
|
93 | } |
|
94 | )); |
|
95 | ||
96 | /** @var mixed $controller */ |
|
97 | $controller = new GenericTemplateRenderController($this->controllerHelper, $this->argumentCompiler, [ |
|
98 | 'template' => "@foo/bar/baz.html", |
|
99 | 'authorization-attribute' => 'some-attribute', |
|
100 | ]); |
|
101 | ||
102 | $controller->renderTemplate($request); |
|
103 | } |
|
104 | ||
105 | /** |
|
106 | * @test |
@@ 207-235 (lines=29) @@ | ||
204 | /** |
|
205 | * @test |
|
206 | */ |
|
207 | public function shouldCheckIfAccessIsGranted() |
|
208 | { |
|
209 | $this->expectException(AccessDeniedException::class); |
|
210 | ||
211 | /** @var Request $request */ |
|
212 | $request = $this->createMock(Request::class); |
|
213 | ||
214 | $this->controllerHelper->expects($this->once())->method('denyAccessUnlessGranted')->with( |
|
215 | $this->equalTo('bar'), |
|
216 | $this->identicalTo($request) |
|
217 | )->will($this->returnCallback( |
|
218 | function () { |
|
219 | throw new AccessDeniedException("Lorem ipsum"); |
|
220 | } |
|
221 | )); |
|
222 | ||
223 | $controller = new GenericServiceInvokeController( |
|
224 | $this->controllerHelper, |
|
225 | $this->argumentCompiler, |
|
226 | $this->container, |
|
227 | [ |
|
228 | 'service' => 'some_service', |
|
229 | 'method' => 'doFoo', |
|
230 | 'authorization-attributes' => 'bar' |
|
231 | ] |
|
232 | ); |
|
233 | ||
234 | $controller->callService($request); |
|
235 | } |
|
236 | ||
237 | /** |
|
238 | * @test |