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