Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HttpKernel] added a setter for the headers property in the HttpExcep…
…tion
- Loading branch information
Showing
17 changed files
with
623 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/Symfony/Component/HttpKernel/Tests/Exception/AccessdeniedHttpExceptionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\HttpKernel\Tests\Exception; | ||
|
||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; | ||
|
||
/** | ||
* Test the AccessDeniedHttpException class. | ||
*/ | ||
class AccessDeniedHttpExceptionTest extends HttpExceptionTest | ||
{ | ||
/** | ||
* 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()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\HttpKernel\Tests\Exception; | ||
|
||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; | ||
|
||
/** | ||
* Test the BadRequestHttpException class. | ||
*/ | ||
class BadRequestHttpExceptionTest extends HttpExceptionTest | ||
{ | ||
/** | ||
* 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()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\HttpKernel\Tests\Exception; | ||
|
||
use Symfony\Component\HttpKernel\Exception\ConflictHttpException; | ||
|
||
/** | ||
* Test the ConflictHttpException class. | ||
*/ | ||
class ConflictHttpExceptionTest extends HttpExceptionTest | ||
{ | ||
/** | ||
* 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()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\HttpKernel\Tests\Exception; | ||
|
||
use Symfony\Component\HttpKernel\Exception\GoneHttpException; | ||
|
||
/** | ||
* Test the GoneHttpException class. | ||
*/ | ||
class GoneHttpExceptionTest extends HttpExceptionTest | ||
{ | ||
/** | ||
* 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()); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\HttpKernel\Tests\Exception; | ||
|
||
use Symfony\Component\HttpKernel\Exception\HttpException; | ||
|
||
/** | ||
* Test the HttpException class. | ||
*/ | ||
class HttpExceptionTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* 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. | ||
*/ | ||
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()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\HttpKernel\Tests\Exception; | ||
|
||
use Symfony\Component\HttpKernel\Exception\LengthRequiredHttpException; | ||
|
||
/** | ||
* Test the LengthRequiredHttpException class. | ||
*/ | ||
class LengthRequiredHttpExceptionTest extends HttpExceptionTest | ||
{ | ||
/** | ||
* 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()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\HttpKernel\Tests\Exception; | ||
|
||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; | ||
|
||
/** | ||
* Test the MethodNotAllowedHttpException class. | ||
*/ | ||
class MethodNotAllowedHttpExceptionTest extends HttpExceptionTest | ||
{ | ||
/** | ||
* 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()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\HttpKernel\Tests\Exception; | ||
|
||
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException; | ||
|
||
/** | ||
* Test the NotAcceptableHttpException class. | ||
*/ | ||
class NotAcceptableHttpExceptionTest extends HttpExceptionTest | ||
{ | ||
/** | ||
* 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()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\HttpKernel\Tests\Exception; | ||
|
||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
|
||
/** | ||
* Test the NotFoundHttpException class. | ||
*/ | ||
class NotFoundHttpExceptionTest extends HttpExceptionTest | ||
{ | ||
/** | ||
* 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()); | ||
} | ||
} |
Oops, something went wrong.