@@ -28,7 +28,7 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | public function testAssertCanBeRegistered() |
| 30 | 30 | { |
| 31 | - $this->specify('verify serviceProvider is registered', function () { |
|
| 31 | + $this->specify('verify serviceProvider is registered', function() { |
|
| 32 | 32 | $service = $this->app->make(CorsService::class); |
| 33 | 33 | verify($service)->isInstanceOf(CorsService::class); |
| 34 | 34 | }); |
@@ -99,7 +99,7 @@ |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | if ($this->maxAge) { |
| 102 | - $response->headers->set('Access-Control-Max-Age', (string)$this->maxAge); |
|
| 102 | + $response->headers->set('Access-Control-Max-Age', (string) $this->maxAge); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $allowMethods = $this->isAllMethodsAllowed() |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | public function testAssertIsNotCorsRequest() |
| 28 | 28 | { |
| 29 | 29 | $middleware = new CorsMiddleware(new CorsService()); |
| 30 | - $this->specify('verify middleware is not cors request', function () use ($middleware) { |
|
| 31 | - verify($middleware->handle(new Request(), function () { |
|
| 30 | + $this->specify('verify middleware is not cors request', function() use ($middleware) { |
|
| 31 | + verify($middleware->handle(new Request(), function() { |
|
| 32 | 32 | return true; |
| 33 | 33 | }))->equals(true); |
| 34 | 34 | }); |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | 'allow_origins' => ['http://example.com'], |
| 44 | 44 | ]); |
| 45 | 45 | $middleware = new CorsMiddleware($service); |
| 46 | - $this->specify('verify middleware is cors request', function () use ($middleware) { |
|
| 46 | + $this->specify('verify middleware is cors request', function() use ($middleware) { |
|
| 47 | 47 | $req = new Request(); |
| 48 | 48 | $req->headers->set('Origin', 'http://example.com'); |
| 49 | - $res = $middleware->handle($req, function () { |
|
| 49 | + $res = $middleware->handle($req, function() { |
|
| 50 | 50 | return new JsonResponse(); |
| 51 | 51 | }); |
| 52 | 52 | |
@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | 'allow_origins' => ['http://foo.com'], |
| 59 | 59 | ]); |
| 60 | 60 | $middleware = new CorsMiddleware($service); |
| 61 | - $this->specify('Closure is called even if origin is not allowed', function () use ($middleware) { |
|
| 61 | + $this->specify('Closure is called even if origin is not allowed', function() use ($middleware) { |
|
| 62 | 62 | $req = new Request(); |
| 63 | 63 | $req->headers->set('Origin', 'http://bar.com'); |
| 64 | - $res = $middleware->handle($req, function () { |
|
| 64 | + $res = $middleware->handle($req, function() { |
|
| 65 | 65 | $res = new JsonResponse(); |
| 66 | 66 | $res->headers->set('X-Closure-Called', 1); |
| 67 | 67 | return $res; |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | 'allow_methods' => ['*'], |
| 82 | 82 | ]); |
| 83 | 83 | $middleware = new CorsMiddleware($service); |
| 84 | - $this->specify('verify middleware is preflight request', function () use ($middleware) { |
|
| 84 | + $this->specify('verify middleware is preflight request', function() use ($middleware) { |
|
| 85 | 85 | $req = new Request(); |
| 86 | 86 | $req->setMethod('OPTIONS'); |
| 87 | 87 | $req->headers->set('Origin', 'http://example.com'); |
| 88 | 88 | $req->headers->set('Access-Control-Request-Method', 'GET'); |
| 89 | 89 | |
| 90 | - $res = $middleware->handle($req, function () { |
|
| 90 | + $res = $middleware->handle($req, function() { |
|
| 91 | 91 | return new JsonResponse(); |
| 92 | 92 | }); |
| 93 | 93 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public function testServiceConfig() |
| 41 | 41 | { |
| 42 | 42 | // service config max_age is less than zero |
| 43 | - $this->assertThrows(\InvalidArgumentException::class, function () { |
|
| 43 | + $this->assertThrows(\InvalidArgumentException::class, function() { |
|
| 44 | 44 | new CorsService(['max_age' => -1]); |
| 45 | 45 | }); |
| 46 | 46 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $this->request = new Request; |
| 57 | 57 | |
| 58 | - $this->specify('200 response when origin, method and headers are allowed', function () { |
|
| 58 | + $this->specify('200 response when origin, method and headers are allowed', function() { |
|
| 59 | 59 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 60 | 60 | $this->request->headers->set('Access-Control-Request-Method', 'POST'); |
| 61 | 61 | $this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | $this->request = new Request; |
| 75 | 75 | |
| 76 | - $this->specify('response headers are set', function () { |
|
| 76 | + $this->specify('response headers are set', function() { |
|
| 77 | 77 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 78 | 78 | $this->request->headers->set('Access-Control-Request-Method', 'POST'); |
| 79 | 79 | $this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | $this->request = new Request; |
| 97 | 97 | |
| 98 | - $this->specify('regression test for issue #31', function () { |
|
| 98 | + $this->specify('regression test for issue #31', function() { |
|
| 99 | 99 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 100 | 100 | $this->request->headers->set('Access-Control-Request-Method', 'POST'); |
| 101 | 101 | $this->request->headers->set('Access-Control-Request-Headers', 'accept,authorization, content-type'); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $this->request = new Request; |
| 120 | 120 | |
| 121 | - $this->specify('response credentials header is set', function () { |
|
| 121 | + $this->specify('response credentials header is set', function() { |
|
| 122 | 122 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 123 | 123 | $this->request->headers->set('Access-Control-Request-Method', 'POST'); |
| 124 | 124 | $this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $this->request = new Request; |
| 139 | 139 | |
| 140 | - $this->specify('response max-age header is set', function () { |
|
| 140 | + $this->specify('response max-age header is set', function() { |
|
| 141 | 141 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 142 | 142 | $this->request->headers->set('Access-Control-Request-Method', 'POST'); |
| 143 | 143 | $this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | 'allow_origins' => ['*'], |
| 159 | 159 | ]); |
| 160 | 160 | |
| 161 | - $this->specify('response origin header is set', function () { |
|
| 161 | + $this->specify('response origin header is set', function() { |
|
| 162 | 162 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 163 | 163 | |
| 164 | 164 | $response = $this->service->handleRequest($this->request, new Response()); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | 'allow_origins' => ['*'], |
| 171 | 171 | ]); |
| 172 | 172 | |
| 173 | - $this->specify('response vary header is not set when all origins are allowed', function () { |
|
| 173 | + $this->specify('response vary header is not set when all origins are allowed', function() { |
|
| 174 | 174 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 175 | 175 | |
| 176 | 176 | $response = new Response(); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | 'allow_origins' => ['http://foo.com'], |
| 185 | 185 | ]); |
| 186 | 186 | |
| 187 | - $this->specify('response vary header is set', function () { |
|
| 187 | + $this->specify('response vary header is set', function() { |
|
| 188 | 188 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 189 | 189 | $this->request->headers->set('Vary', 'Accept-Encoding'); |
| 190 | 190 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | 'allow_credentials' => true, |
| 201 | 201 | ]); |
| 202 | 202 | |
| 203 | - $this->specify('response credentials header is set', function () { |
|
| 203 | + $this->specify('response credentials header is set', function() { |
|
| 204 | 204 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 205 | 205 | |
| 206 | 206 | $response = $this->service->handleRequest($this->request, new Response()); |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | 'expose_headers' => ['Accept', 'Authorization', 'Content-Type'], |
| 216 | 216 | ]); |
| 217 | 217 | |
| 218 | - $this->specify('response expose headers header is set', function () { |
|
| 218 | + $this->specify('response expose headers header is set', function() { |
|
| 219 | 219 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 220 | 220 | |
| 221 | 221 | $response = $this->service->handleRequest($this->request, new Response()); |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | 'allow_origins' => ['http://foo.com', 'http://notbar.com'], |
| 228 | 228 | ]); |
| 229 | 229 | |
| 230 | - $this->specify('response origin header is not set when origin is not allowed', function () { |
|
| 230 | + $this->specify('response origin header is not set when origin is not allowed', function() { |
|
| 231 | 231 | $this->request->headers->set('Origin', 'http://bar.com'); |
| 232 | 232 | |
| 233 | 233 | $response = $this->service->handleRequest($this->request, new Response()); |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | $this->request = new Request; |
| 245 | 245 | |
| 246 | - $this->specify('cors request is recognized', function () { |
|
| 246 | + $this->specify('cors request is recognized', function() { |
|
| 247 | 247 | verify($this->service->isCorsRequest($this->request))->false(); |
| 248 | 248 | |
| 249 | 249 | $this->request->headers->set('Origin', 'http://foo.com'); |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | $this->request = new Request; |
| 260 | 260 | |
| 261 | - $this->specify('preflight request is recognized', function () { |
|
| 261 | + $this->specify('preflight request is recognized', function() { |
|
| 262 | 262 | verify($this->service->isPreflightRequest($this->request))->false(); |
| 263 | 263 | |
| 264 | 264 | $this->request->setMethod('OPTIONS'); |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | 'allow_origins' => ['http://*.foo.com', 'http://notbar.com'], |
| 286 | 286 | ]); |
| 287 | 287 | |
| 288 | - $this->specify('response origin header is set when origin is match to a pattern', function () { |
|
| 288 | + $this->specify('response origin header is set when origin is match to a pattern', function() { |
|
| 289 | 289 | $this->request->headers->set('Origin', 'http://bar.foo.com'); |
| 290 | 290 | |
| 291 | 291 | $response = $this->service->handleRequest($this->request, new Response()); |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | 'allow_origins' => ['http://*.foo.com', 'http://notbar.com'], |
| 306 | 306 | ]); |
| 307 | 307 | |
| 308 | - $this->specify('response origin header is not set when origin is not a match to a pattern', function () { |
|
| 308 | + $this->specify('response origin header is not set when origin is not a match to a pattern', function() { |
|
| 309 | 309 | $this->request->headers->set('Origin', 'http://bar.com'); |
| 310 | 310 | |
| 311 | 311 | $response = $this->service->handleRequest($this->request, new Response()); |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | protected function registerBindings(): void |
| 30 | 30 | { |
| 31 | 31 | // TODO: Change to bind the implementation to the interface instead. |
| 32 | - $this->app->bind(CorsService::class, function () { |
|
| 32 | + $this->app->bind(CorsService::class, function() { |
|
| 33 | 33 | return new CorsService(config(self::CONFIG_KEY)); |
| 34 | 34 | }); |
| 35 | 35 | |