HttpExceptionTest.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Symfony\Component\HttpKernel\Tests\Exception;
  3. use PHPUnit\Framework\TestCase;
  4. use Symfony\Component\HttpKernel\Exception\HttpException;
  5. class HttpExceptionTest extends TestCase
  6. {
  7. public function headerDataProvider()
  8. {
  9. return array(
  10. array(array('X-Test' => 'Test')),
  11. array(array('X-Test' => 1)),
  12. array(
  13. array(
  14. array('X-Test' => 'Test'),
  15. array('X-Test-2' => 'Test-2'),
  16. ),
  17. ),
  18. );
  19. }
  20. public function testHeadersDefault()
  21. {
  22. $exception = $this->createException();
  23. $this->assertSame(array(), $exception->getHeaders());
  24. }
  25. /**
  26. * @dataProvider headerDataProvider
  27. */
  28. public function testHeadersConstructor($headers)
  29. {
  30. $exception = new HttpException(200, null, null, $headers);
  31. $this->assertSame($headers, $exception->getHeaders());
  32. }
  33. /**
  34. * @dataProvider headerDataProvider
  35. */
  36. public function testHeadersSetter($headers)
  37. {
  38. $exception = $this->createException();
  39. $exception->setHeaders($headers);
  40. $this->assertSame($headers, $exception->getHeaders());
  41. }
  42. protected function createException()
  43. {
  44. return new HttpException(200);
  45. }
  46. }