Brak opisu

HttpExceptionTest.php 1.3KB

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