ServiceUnavailableHttpExceptionTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Symfony\Component\HttpKernel\Tests\Exception;
  3. use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
  4. class ServiceUnavailableHttpExceptionTest extends HttpExceptionTest
  5. {
  6. public function testHeadersDefaultRetryAfter()
  7. {
  8. $exception = new ServiceUnavailableHttpException(10);
  9. $this->assertSame(['Retry-After' => 10], $exception->getHeaders());
  10. }
  11. public function testWithHeaderConstruct()
  12. {
  13. $headers = [
  14. 'Cache-Control' => 'public, s-maxage=1337',
  15. ];
  16. $exception = new ServiceUnavailableHttpException(1337, null, null, null, $headers);
  17. $headers['Retry-After'] = 1337;
  18. $this->assertSame($headers, $exception->getHeaders());
  19. }
  20. /**
  21. * @dataProvider headerDataProvider
  22. */
  23. public function testHeadersSetter($headers)
  24. {
  25. $exception = new ServiceUnavailableHttpException(10);
  26. $exception->setHeaders($headers);
  27. $this->assertSame($headers, $exception->getHeaders());
  28. }
  29. protected function createException()
  30. {
  31. return new ServiceUnavailableHttpException();
  32. }
  33. }