|
4 | 4 |
|
5 | 5 | use ForceHttpsModule\Listener\ForceHttps; |
6 | 6 | use Kahlan\Plugin\Double; |
| 7 | +use Kahlan\Plugin\Quit; |
| 8 | +use Kahlan\QuitException; |
7 | 9 | use Zend\Console\Console; |
8 | 10 | use Zend\EventManager\EventManagerInterface; |
9 | 11 | use Zend\Http\PhpEnvironment\Request; |
|
80 | 82 | $this->request = Double::instance(['extends' => Request::class]); |
81 | 83 | $this->uri = Double::instance(['extends' => Uri::class]); |
82 | 84 | $this->routeMatch = Double::instance(['extends' => RouteMatch::class, 'methods' => '__construct']); |
| 85 | + |
| 86 | + Quit::disable(); |
83 | 87 | }); |
84 | 88 |
|
85 | 89 | context('on current scheme is https', function () { |
|
159 | 163 | ->with('SendResponseListener') |
160 | 164 | ->andReturn($this->sendResponseListener); |
161 | 165 |
|
162 | | - $listener->forceHttpsScheme($this->mvcEvent); |
| 166 | + $closure = function () use ($listener) { |
| 167 | + $listener->forceHttpsScheme($this->mvcEvent); |
| 168 | + }; |
| 169 | + expect($closure)->toThrow(new QuitException('Exit statement occurred', 0)); |
163 | 170 |
|
164 | 171 | expect($this->mvcEvent)->toReceive('getResponse'); |
165 | 172 |
|
|
197 | 204 | ->with('SendResponseListener') |
198 | 205 | ->andReturn($this->sendResponseListener); |
199 | 206 |
|
200 | | - $listener->forceHttpsScheme($this->mvcEvent); |
| 207 | + $closure = function () use ($listener) { |
| 208 | + $listener->forceHttpsScheme($this->mvcEvent); |
| 209 | + }; |
| 210 | + expect($closure)->toThrow(new QuitException('Exit statement occurred', 0)); |
201 | 211 |
|
202 | 212 | expect($this->mvcEvent)->toReceive('getResponse'); |
203 | 213 |
|
|
233 | 243 | ->with('SendResponseListener') |
234 | 244 | ->andReturn($this->sendResponseListener); |
235 | 245 |
|
236 | | - $listener->forceHttpsScheme($this->mvcEvent); |
| 246 | + $closure = function () use ($listener) { |
| 247 | + $listener->forceHttpsScheme($this->mvcEvent); |
| 248 | + }; |
| 249 | + expect($closure)->toThrow(new QuitException('Exit statement occurred', 0)); |
237 | 250 |
|
238 | 251 | expect($this->mvcEvent)->toReceive('getResponse'); |
239 | 252 | expect($this->response)->toReceive('getHeaders', 'addHeaderLine')->with('Location', 'https://example.com/about'); |
|
271 | 284 | ->with('SendResponseListener') |
272 | 285 | ->andReturn($this->sendResponseListener); |
273 | 286 |
|
274 | | - $listener->forceHttpsScheme($this->mvcEvent); |
| 287 | + $closure = function () use ($listener) { |
| 288 | + $listener->forceHttpsScheme($this->mvcEvent); |
| 289 | + }; |
| 290 | + expect($closure)->toThrow(new QuitException('Exit statement occurred', 0)); |
275 | 291 |
|
276 | 292 | expect($this->mvcEvent)->toReceive('getResponse'); |
277 | 293 | expect($this->response)->toReceive('getHeaders', 'addHeaderLine')->with('Location', 'https://www.example.com/about'); |
|
314 | 330 | allow($this->response)->toReceive('setStatusCode')->with(308)->andReturn($this->response); |
315 | 331 | allow($this->response)->toReceive('send'); |
316 | 332 |
|
317 | | - $listener->forceHttpsScheme($this->mvcEvent); |
| 333 | + $closure = function () use ($listener) { |
| 334 | + $listener->forceHttpsScheme($this->mvcEvent); |
| 335 | + }; |
| 336 | + expect($closure)->toThrow(new QuitException('Exit statement occurred', 0)); |
318 | 337 |
|
319 | 338 | expect($this->mvcEvent)->toReceive('getResponse'); |
320 | 339 |
|
|
0 commit comments