TooManyRequestsHttpExceptionTest.php 1.1 KB

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