diff --git a/src/Symfony/Component/HttpKernel/Exception/HttpException.php b/src/Symfony/Component/HttpKernel/Exception/HttpException.php index 4e1b52632b10a..e802752f71f99 100644 --- a/src/Symfony/Component/HttpKernel/Exception/HttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/HttpException.php @@ -38,4 +38,14 @@ public function getHeaders() { return $this->headers; } + + /** + * Set response headers. + * + * @param array $headers Response headers. + */ + public function setHeaders(array $headers) + { + $this->headers = $headers; + } } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/AccessdeniedHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/AccessdeniedHttpExceptionTest.php new file mode 100644 index 0000000000000..62451dbe2543b --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/AccessdeniedHttpExceptionTest.php @@ -0,0 +1,35 @@ +assertSame(array(), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new AccessDeniedHttpException(); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php new file mode 100644 index 0000000000000..67069ba2abf7f --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php @@ -0,0 +1,35 @@ +assertSame(array(), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new BadRequestHttpException(); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php new file mode 100644 index 0000000000000..c830835384b9d --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php @@ -0,0 +1,35 @@ +assertSame(array(), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new ConflictHttpException(); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php new file mode 100644 index 0000000000000..6a710dfc5d81a --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php @@ -0,0 +1,35 @@ +assertSame(array(), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new GoneHttpException(); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php new file mode 100644 index 0000000000000..628eec6555e85 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php @@ -0,0 +1,68 @@ + 'Test')), + array(array('X-Test' => 1)), + array( + array( + array('X-Test' => 'Test'), + array('X-Test-2' => 'Test-2'), + ), + ), + ); + } + + /** + * Test that the default headers is an empty array. + */ + public function testHeadersDefault() + { + $exception = new HttpException(200); + $this->assertSame(array(), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the constructor parameter + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersConstructor($headers) + { + $exception = new HttpException(200, null, null, $headers); + $this->assertSame($headers, $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new HttpException(200); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php new file mode 100644 index 0000000000000..73386f18d561a --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php @@ -0,0 +1,35 @@ +assertSame(array(), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new LengthRequiredHttpException(); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php new file mode 100644 index 0000000000000..3f5a23d1fa112 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php @@ -0,0 +1,35 @@ +assertSame(array('Allow' => 'GET, PUT'), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new MethodNotAllowedHttpException(array('GET')); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php new file mode 100644 index 0000000000000..8a2825262d3cb --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php @@ -0,0 +1,35 @@ +assertSame(array(), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new NotAcceptableHttpException(); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php new file mode 100644 index 0000000000000..8bd2c2ef630c2 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php @@ -0,0 +1,35 @@ +assertSame(array(), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new NotFoundHttpException(); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php new file mode 100644 index 0000000000000..5c7e66b136c81 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php @@ -0,0 +1,35 @@ +assertSame(array(), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new PreconditionFailedHttpException(); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php new file mode 100644 index 0000000000000..e90351603be40 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php @@ -0,0 +1,35 @@ +assertSame(array(), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new PreconditionRequiredHttpException(); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php new file mode 100644 index 0000000000000..f739890d97b39 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php @@ -0,0 +1,45 @@ +assertSame(array(), $exception->getHeaders()); + } + + /** + * Test that the default headers are set correctly + * when the retryAfter parameter is set. + */ + public function testHeadersDefaultRetryAfter() + { + $exception = new ServiceUnavailableHttpException(10); + $this->assertSame(array('Retry-After' => 10), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new ServiceUnavailableHttpException(10); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php new file mode 100644 index 0000000000000..9867831082bfc --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php @@ -0,0 +1,45 @@ +assertSame(array(), $exception->getHeaders()); + } + + /** + * Test that the default headers are set correctly + * when the retryAfter parameter is set. + */ + public function testHeadersDefaultRertyAfter() + { + $exception = new TooManyRequestsHttpException(10); + $this->assertSame(array('Retry-After' => 10), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new TooManyRequestsHttpException(10); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/UnauthorizedHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/UnauthorizedHttpExceptionTest.php new file mode 100644 index 0000000000000..0333026548fd2 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/UnauthorizedHttpExceptionTest.php @@ -0,0 +1,35 @@ +assertSame(array('WWW-Authenticate' => 'Challenge'), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new UnauthorizedHttpException('Challenge'); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php new file mode 100644 index 0000000000000..4ef116af895bf --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php @@ -0,0 +1,35 @@ +assertSame(array(), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new UnprocessableEntityHttpException(10); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php new file mode 100644 index 0000000000000..8b9128ef1f969 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php @@ -0,0 +1,35 @@ +assertSame(array(), $exception->getHeaders()); + } + + /** + * Test that setting the headers using the setter function + * is working as expected. + * + * @param array $headers The headers to set. + * + * @dataProvider headerDataProvider + */ + public function testHeadersSetter($headers) + { + $exception = new UnsupportedMediaTypeHttpException(10); + $exception->setHeaders($headers); + $this->assertSame($headers, $exception->getHeaders()); + } +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy