@@ 148-175 (lines=28) @@ | ||
145 | /** |
|
146 | * @test |
|
147 | */ |
|
148 | public function shouldCheckIfAccessIsGranted() |
|
149 | { |
|
150 | $this->expectException(AccessDeniedException::class); |
|
151 | ||
152 | /** @var mixed $entity */ |
|
153 | $entity = new SampleEntity(); |
|
154 | ||
155 | $this->controllerHelper->expects($this->once())->method('findEntity')->with( |
|
156 | $this->equalTo(SampleEntity::class), |
|
157 | $this->equalTo("some-id") |
|
158 | )->willReturn($entity); |
|
159 | ||
160 | $this->controllerHelper->expects($this->once())->method('denyAccessUnlessGranted')->with( |
|
161 | $this->equalTo('some-attribute'), |
|
162 | $this->identicalTo($entity) |
|
163 | )->will($this->returnCallback( |
|
164 | function () { |
|
165 | throw new AccessDeniedException('Lorem ipsum!'); |
|
166 | } |
|
167 | )); |
|
168 | ||
169 | $controller = new GenericEntityFetchController($this->controllerHelper, [ |
|
170 | 'entity-class' => SampleEntity::class, |
|
171 | 'authorization-attribute' => 'some-attribute', |
|
172 | ]); |
|
173 | ||
174 | $controller->fetchEntity("some-id"); |
|
175 | } |
|
176 | ||
177 | /** |
|
178 | * @test |
@@ 102-128 (lines=27) @@ | ||
99 | /** |
|
100 | * @test |
|
101 | */ |
|
102 | public function shouldCheckIfAccessIsGranted() |
|
103 | { |
|
104 | $this->expectException(AccessDeniedException::class); |
|
105 | ||
106 | $entity = new SampleEntity(); |
|
107 | ||
108 | $this->controllerHelper->expects($this->once())->method('findEntity')->with( |
|
109 | $this->equalTo(SampleEntity::class), |
|
110 | $this->equalTo("some-id") |
|
111 | )->willReturn($entity); |
|
112 | ||
113 | $this->controllerHelper->expects($this->once())->method('denyAccessUnlessGranted')->with( |
|
114 | $this->equalTo('some-attribute'), |
|
115 | $this->identicalTo($entity) |
|
116 | )->will($this->returnCallback( |
|
117 | function () { |
|
118 | throw new AccessDeniedException('Lorem ipsum!'); |
|
119 | } |
|
120 | )); |
|
121 | ||
122 | $controller = new GenericEntityRemoveController($this->controllerHelper, [ |
|
123 | 'entity-class' => SampleEntity::class, |
|
124 | 'authorization-attribute' => 'some-attribute', |
|
125 | ]); |
|
126 | ||
127 | $controller->removeEntity("some-id"); |
|
128 | } |
|
129 | ||
130 | /** |
|
131 | * @test |