From c38c17bc8c2ee573a725ad63bb04f7b2e54ec188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ty=C3=A1s=20Somfai?= Date: Tue, 22 Dec 2015 17:59:45 +0100 Subject: [PATCH 1/2] added a setter for the headers property in the HttpException --- .../HttpKernel/Exception/HttpException.php | 10 +++ .../AccessdeniedHttpExceptionTest.php | 54 +++++++++++++++ .../Exception/BadRequestHttpExceptionTest.php | 54 +++++++++++++++ .../Exception/ConflictHttpExceptionTest.php | 54 +++++++++++++++ .../Tests/Exception/GoneHttpExceptionTest.php | 54 +++++++++++++++ .../Tests/Exception/HttpExceptionTest.php | 68 +++++++++++++++++++ .../LengthRequiredHttpExceptionTest.php | 54 +++++++++++++++ .../MethodNotAllowedHttpExceptionTest.php | 54 +++++++++++++++ .../NotAcceptableHttpExceptionTest.php | 54 +++++++++++++++ .../Exception/NotFoundHttpExceptionTest.php | 54 +++++++++++++++ .../PreconditionFailedHttpExceptionTest.php | 54 +++++++++++++++ .../PreconditionRequiredHttpExceptionTest.php | 54 +++++++++++++++ .../ServiceUnavailableHttpExceptionTest.php | 54 +++++++++++++++ .../TooManyRequestsHttpExceptionTest.php | 54 +++++++++++++++ .../UnauthorizedHttpExceptionTest.php | 54 +++++++++++++++ .../UnprocessableEntityHttpExceptionTest.php | 54 +++++++++++++++ .../UnsupportedMediaTypeHttpExceptionTest.php | 54 +++++++++++++++ 17 files changed, 888 insertions(+) create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/AccessdeniedHttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/UnauthorizedHttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php 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..3b9d02e619da4 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/AccessdeniedHttpExceptionTest.php @@ -0,0 +1,54 @@ + '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 AccessDeniedHttpException(); + $this->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..27d6bec025736 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php @@ -0,0 +1,54 @@ + '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 BadRequestHttpException(); + $this->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..0562fa5a047a3 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php @@ -0,0 +1,54 @@ + '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 ConflictHttpException(); + $this->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..1c4c28d1a3021 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php @@ -0,0 +1,54 @@ + '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 GoneHttpException(); + $this->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..3002e93c1cd87 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php @@ -0,0 +1,54 @@ + '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 LengthRequiredHttpException(); + $this->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..2b07dd5e5b7a1 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php @@ -0,0 +1,54 @@ + 'Test')), + array(array('X-Test' => 1)), + array( + array( + array('X-Test' => 'Test'), + array('X-Test-2' => 'Test-2'), + ), + ), + ); + } + + /** + * Test that the default headers is set as expected. + */ + public function testHeadersDefault() + { + $exception = new MethodNotAllowedHttpException(array('GET', 'PUT')); + $this->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..96536a6ecd886 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php @@ -0,0 +1,54 @@ + '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 NotAcceptableHttpException(); + $this->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..8e60f217734c2 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php @@ -0,0 +1,54 @@ + '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 NotFoundHttpException(); + $this->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..45fdc09442034 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php @@ -0,0 +1,54 @@ + '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 PreconditionFailedHttpException(); + $this->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..e0bc82760fb0f --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php @@ -0,0 +1,54 @@ + '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 PreconditionRequiredHttpException(); + $this->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..d646c170a4f72 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php @@ -0,0 +1,54 @@ + '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 ServiceUnavailableHttpException(); + $this->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 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..f056c1fd47ff2 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php @@ -0,0 +1,54 @@ + '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 TooManyRequestsHttpException(); + $this->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 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..6f5cf408c2b32 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/UnauthorizedHttpExceptionTest.php @@ -0,0 +1,54 @@ + 'Test')), + array(array('X-Test' => 1)), + array( + array( + array('X-Test' => 'Test'), + array('X-Test-2' => 'Test-2'), + ), + ), + ); + } + + /** + * Test that the default headers is set as expected. + */ + public function testHeadersDefault() + { + $exception = new UnauthorizedHttpException('Challenge'); + $this->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..e2119b8045030 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php @@ -0,0 +1,54 @@ + '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 UnprocessableEntityHttpException(); + $this->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..fefa68f7ae293 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php @@ -0,0 +1,54 @@ + '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 UnsupportedMediaTypeHttpException(); + $this->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()); + } +} From c86ace08d497dd9876f408fdd2c215761a9fa1b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ty=C3=A1s=20Somfai?= Date: Mon, 28 Dec 2015 19:37:35 +0100 Subject: [PATCH 2/2] reorganized *HttpExceptionTest classes to prevent code duplication --- .../AccessdeniedHttpExceptionTest.php | 21 +------------- .../Exception/BadRequestHttpExceptionTest.php | 21 +------------- .../Exception/ConflictHttpExceptionTest.php | 21 +------------- .../Tests/Exception/GoneHttpExceptionTest.php | 21 +------------- .../LengthRequiredHttpExceptionTest.php | 21 +------------- .../MethodNotAllowedHttpExceptionTest.php | 21 +------------- .../NotAcceptableHttpExceptionTest.php | 21 +------------- .../Exception/NotFoundHttpExceptionTest.php | 21 +------------- .../PreconditionFailedHttpExceptionTest.php | 21 +------------- .../PreconditionRequiredHttpExceptionTest.php | 21 +------------- .../ServiceUnavailableHttpExceptionTest.php | 29 +++++++------------ .../TooManyRequestsHttpExceptionTest.php | 29 +++++++------------ .../UnauthorizedHttpExceptionTest.php | 21 +------------- .../UnprocessableEntityHttpExceptionTest.php | 21 +------------- .../UnsupportedMediaTypeHttpExceptionTest.php | 21 +------------- 15 files changed, 33 insertions(+), 298 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/AccessdeniedHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/AccessdeniedHttpExceptionTest.php index 3b9d02e619da4..62451dbe2543b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/AccessdeniedHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/AccessdeniedHttpExceptionTest.php @@ -7,27 +7,8 @@ /** * Test the AccessDeniedHttpException class. */ -class AccessDeniedHttpExceptionTest extends \PHPUnit_Framework_TestCase +class AccessDeniedHttpExceptionTest extends HttpExceptionTest { - /** - * Provides header data for the tests. - * - * @return array - */ - public function headerDataProvider() - { - return array( - array(array('X-Test' => '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. */ diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php index 27d6bec025736..67069ba2abf7f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php @@ -7,27 +7,8 @@ /** * Test the BadRequestHttpException class. */ -class BadRequestHttpExceptionTest extends \PHPUnit_Framework_TestCase +class BadRequestHttpExceptionTest extends HttpExceptionTest { - /** - * Provides header data for the tests. - * - * @return array - */ - public function headerDataProvider() - { - return array( - array(array('X-Test' => '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. */ diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php index 0562fa5a047a3..c830835384b9d 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php @@ -7,27 +7,8 @@ /** * Test the ConflictHttpException class. */ -class ConflictHttpExceptionTest extends \PHPUnit_Framework_TestCase +class ConflictHttpExceptionTest extends HttpExceptionTest { - /** - * Provides header data for the tests. - * - * @return array - */ - public function headerDataProvider() - { - return array( - array(array('X-Test' => '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. */ diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php index 1c4c28d1a3021..6a710dfc5d81a 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php @@ -7,27 +7,8 @@ /** * Test the GoneHttpException class. */ -class GoneHttpExceptionTest extends \PHPUnit_Framework_TestCase +class GoneHttpExceptionTest extends HttpExceptionTest { - /** - * Provides header data for the tests. - * - * @return array - */ - public function headerDataProvider() - { - return array( - array(array('X-Test' => '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. */ diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php index 3002e93c1cd87..73386f18d561a 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php @@ -7,27 +7,8 @@ /** * Test the LengthRequiredHttpException class. */ -class LengthRequiredHttpExceptionTest extends \PHPUnit_Framework_TestCase +class LengthRequiredHttpExceptionTest extends HttpExceptionTest { - /** - * Provides header data for the tests. - * - * @return array - */ - public function headerDataProvider() - { - return array( - array(array('X-Test' => '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. */ diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php index 2b07dd5e5b7a1..3f5a23d1fa112 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php @@ -7,27 +7,8 @@ /** * Test the MethodNotAllowedHttpException class. */ -class MethodNotAllowedHttpExceptionTest extends \PHPUnit_Framework_TestCase +class MethodNotAllowedHttpExceptionTest extends HttpExceptionTest { - /** - * Provides header data for the tests. - * - * @return array - */ - public function headerDataProvider() - { - return array( - array(array('X-Test' => 'Test')), - array(array('X-Test' => 1)), - array( - array( - array('X-Test' => 'Test'), - array('X-Test-2' => 'Test-2'), - ), - ), - ); - } - /** * Test that the default headers is set as expected. */ diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php index 96536a6ecd886..8a2825262d3cb 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php @@ -7,27 +7,8 @@ /** * Test the NotAcceptableHttpException class. */ -class NotAcceptableHttpExceptionTest extends \PHPUnit_Framework_TestCase +class NotAcceptableHttpExceptionTest extends HttpExceptionTest { - /** - * Provides header data for the tests. - * - * @return array - */ - public function headerDataProvider() - { - return array( - array(array('X-Test' => '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. */ diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php index 8e60f217734c2..8bd2c2ef630c2 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php @@ -7,27 +7,8 @@ /** * Test the NotFoundHttpException class. */ -class NotFoundHttpExceptionTest extends \PHPUnit_Framework_TestCase +class NotFoundHttpExceptionTest extends HttpExceptionTest { - /** - * Provides header data for the tests. - * - * @return array - */ - public function headerDataProvider() - { - return array( - array(array('X-Test' => '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. */ diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php index 45fdc09442034..5c7e66b136c81 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php @@ -7,27 +7,8 @@ /** * Test the PreconditionFailedHttpException class. */ -class PreconditionFailedHttpExceptionTest extends \PHPUnit_Framework_TestCase +class PreconditionFailedHttpExceptionTest extends HttpExceptionTest { - /** - * Provides header data for the tests. - * - * @return array - */ - public function headerDataProvider() - { - return array( - array(array('X-Test' => '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. */ diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php index e0bc82760fb0f..e90351603be40 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php @@ -7,27 +7,8 @@ /** * Test the PreconditionRequiredHttpException class. */ -class PreconditionRequiredHttpExceptionTest extends \PHPUnit_Framework_TestCase +class PreconditionRequiredHttpExceptionTest extends HttpExceptionTest { - /** - * Provides header data for the tests. - * - * @return array - */ - public function headerDataProvider() - { - return array( - array(array('X-Test' => '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. */ diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php index d646c170a4f72..f739890d97b39 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php @@ -7,34 +7,25 @@ /** * Test the ServiceUnavailableHttpException class. */ -class ServiceUnavailableHttpExceptionTest extends \PHPUnit_Framework_TestCase +class ServiceUnavailableHttpExceptionTest extends HttpExceptionTest { /** - * Provides header data for the tests. - * - * @return array + * Test that the default headers is an empty array. */ - public function headerDataProvider() + public function testHeadersDefault() { - return array( - array(array('X-Test' => 'Test')), - array(array('X-Test' => 1)), - array( - array( - array('X-Test' => 'Test'), - array('X-Test-2' => 'Test-2'), - ), - ), - ); + $exception = new ServiceUnavailableHttpException(); + $this->assertSame(array(), $exception->getHeaders()); } /** - * Test that the default headers is an empty array. + * Test that the default headers are set correctly + * when the retryAfter parameter is set. */ - public function testHeadersDefault() + public function testHeadersDefaultRetryAfter() { - $exception = new ServiceUnavailableHttpException(); - $this->assertSame(array(), $exception->getHeaders()); + $exception = new ServiceUnavailableHttpException(10); + $this->assertSame(array('Retry-After' => 10), $exception->getHeaders()); } /** diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php index f056c1fd47ff2..9867831082bfc 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php @@ -7,34 +7,25 @@ /** * Test the TooManyRequestsHttpException class. */ -class TooManyRequestsHttpExceptionTest extends \PHPUnit_Framework_TestCase +class TooManyRequestsHttpExceptionTest extends HttpExceptionTest { /** - * Provides header data for the tests. - * - * @return array + * Test that the default headers is an empty array. */ - public function headerDataProvider() + public function testHeadersDefault() { - return array( - array(array('X-Test' => 'Test')), - array(array('X-Test' => 1)), - array( - array( - array('X-Test' => 'Test'), - array('X-Test-2' => 'Test-2'), - ), - ), - ); + $exception = new TooManyRequestsHttpException(); + $this->assertSame(array(), $exception->getHeaders()); } /** - * Test that the default headers is an empty array. + * Test that the default headers are set correctly + * when the retryAfter parameter is set. */ - public function testHeadersDefault() + public function testHeadersDefaultRertyAfter() { - $exception = new TooManyRequestsHttpException(); - $this->assertSame(array(), $exception->getHeaders()); + $exception = new TooManyRequestsHttpException(10); + $this->assertSame(array('Retry-After' => 10), $exception->getHeaders()); } /** diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/UnauthorizedHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/UnauthorizedHttpExceptionTest.php index 6f5cf408c2b32..0333026548fd2 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/UnauthorizedHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/UnauthorizedHttpExceptionTest.php @@ -7,27 +7,8 @@ /** * Test the UnauthorizedHttpException class. */ -class UnauthorizedHttpExceptionTest extends \PHPUnit_Framework_TestCase +class UnauthorizedHttpExceptionTest extends HttpExceptionTest { - /** - * Provides header data for the tests. - * - * @return array - */ - public function headerDataProvider() - { - return array( - array(array('X-Test' => 'Test')), - array(array('X-Test' => 1)), - array( - array( - array('X-Test' => 'Test'), - array('X-Test-2' => 'Test-2'), - ), - ), - ); - } - /** * Test that the default headers is set as expected. */ diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php index e2119b8045030..4ef116af895bf 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php @@ -7,27 +7,8 @@ /** * Test the UnprocessableEntityHttpException class. */ -class UnprocessableEntityHttpExceptionTest extends \PHPUnit_Framework_TestCase +class UnprocessableEntityHttpExceptionTest extends HttpExceptionTest { - /** - * Provides header data for the tests. - * - * @return array - */ - public function headerDataProvider() - { - return array( - array(array('X-Test' => '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. */ diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php index fefa68f7ae293..8b9128ef1f969 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php @@ -7,27 +7,8 @@ /** * Test the UnsupportedMediaTypeHttpException class. */ -class UnsupportedMediaTypeHttpExceptionTest extends \PHPUnit_Framework_TestCase +class UnsupportedMediaTypeHttpExceptionTest extends HttpExceptionTest { - /** - * Provides header data for the tests. - * - * @return array - */ - public function headerDataProvider() - { - return array( - array(array('X-Test' => '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. */