|
205 | 205 |
|
206 | 206 | }); |
207 | 207 |
|
| 208 | + it('not redirect if force_all_routes is true and route name in exclude_specific_routes config', function () { |
| 209 | + |
| 210 | + $listener = new ForceHttps([ |
| 211 | + 'enable' => true, |
| 212 | + 'force_all_routes' => true, |
| 213 | + 'exclude_specific_routes' => [ |
| 214 | + 'checkout' |
| 215 | + ], |
| 216 | + 'force_specific_routes' => [], |
| 217 | + ]); |
| 218 | + |
| 219 | + allow($this->mvcEvent)->toReceive('getRequest')->andReturn($this->request); |
| 220 | + allow($this->request)->toReceive('getUri')->andReturn($this->uri); |
| 221 | + allow($this->uri)->toReceive('getScheme')->andReturn('http'); |
| 222 | + allow($this->mvcEvent)->toReceive('getRouteMatch')->andReturn($this->routeMatch); |
| 223 | + allow($this->routeMatch)->toReceive('getMatchedRouteName')->andReturn('checkout'); |
| 224 | + allow($this->uri)->toReceive('toString')->andReturn('http://example.com/about'); |
| 225 | + allow($this->mvcEvent)->toReceive('getResponse')->andReturn($this->response); |
| 226 | + allow($this->response)->toReceive('send'); |
| 227 | + |
| 228 | + $listener->forceHttpsScheme($this->mvcEvent); |
| 229 | + expect($this->mvcEvent)->toReceive('getResponse'); |
| 230 | + }); |
| 231 | + |
| 232 | + |
| 233 | + it('redirect if force_all_routes is true and route name not in exclude_specific_routes config', function () { |
| 234 | + |
| 235 | + $listener = new ForceHttps([ |
| 236 | + 'enable' => true, |
| 237 | + 'force_all_routes' => true, |
| 238 | + 'exclude_specific_routes' => [ |
| 239 | + 'sale' |
| 240 | + ], |
| 241 | + 'force_specific_routes' => [], |
| 242 | + ]); |
| 243 | + |
| 244 | + allow($this->mvcEvent)->toReceive('getRequest')->andReturn($this->request); |
| 245 | + allow($this->request)->toReceive('getUri')->andReturn($this->uri); |
| 246 | + allow($this->uri)->toReceive('getScheme')->andReturn('http'); |
| 247 | + allow($this->mvcEvent)->toReceive('getRouteMatch')->andReturn($this->routeMatch); |
| 248 | + allow($this->routeMatch)->toReceive('getMatchedRouteName')->andReturn('checkout'); |
| 249 | + allow($this->uri)->toReceive('setScheme')->with('https')->andReturn($this->uri); |
| 250 | + allow($this->uri)->toReceive('toString')->andReturn('https://example.com/about'); |
| 251 | + allow($this->mvcEvent)->toReceive('getResponse')->andReturn($this->response); |
| 252 | + allow($this->response)->toReceive('setStatusCode')->with(308)->andReturn($this->response); |
| 253 | + allow($this->response)->toReceive('getHeaders', 'addHeaderLine')->with('Location', 'https://example.com/about'); |
| 254 | + allow($this->response)->toReceive('send'); |
| 255 | + |
| 256 | + $closure = function () use ($listener) { |
| 257 | + $listener->forceHttpsScheme($this->mvcEvent); |
| 258 | + }; |
| 259 | + expect($closure)->toThrow(new QuitException('Exit statement occurred', 0)); |
| 260 | + |
| 261 | + expect($this->mvcEvent)->toReceive('getResponse'); |
| 262 | + }); |
| 263 | + |
208 | 264 | it('redirect if force_all_routes is true', function () { |
209 | 265 |
|
210 | 266 | $listener = new ForceHttps([ |
|
0 commit comments