MethodNotAllowedHttpExceptionTest.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Symfony\Component\HttpKernel\Tests\Exception;
  3. use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
  4. class MethodNotAllowedHttpExceptionTest extends HttpExceptionTest
  5. {
  6. public function testHeadersDefault()
  7. {
  8. $exception = new MethodNotAllowedHttpException(array('GET', 'PUT'));
  9. $this->assertSame(array('Allow' => 'GET, PUT'), $exception->getHeaders());
  10. }
  11. public function testWithHeaderConstruct()
  12. {
  13. $headers = array(
  14. 'Cache-Control' => 'public, s-maxage=1200',
  15. );
  16. $exception = new MethodNotAllowedHttpException(array('get'), null, null, null, $headers);
  17. $headers['Allow'] = 'GET';
  18. $this->assertSame($headers, $exception->getHeaders());
  19. }
  20. /**
  21. * @dataProvider headerDataProvider
  22. */
  23. public function testHeadersSetter($headers)
  24. {
  25. $exception = new MethodNotAllowedHttpException(array('GET'));
  26. $exception->setHeaders($headers);
  27. $this->assertSame($headers, $exception->getHeaders());
  28. }
  29. }