TooManyRequestsHttpExceptionTest.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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(array('Retry-After' => 10), $exception->getHeaders());
  10. }
  11. public function testWithHeaderConstruct()
  12. {
  13. $headers = array(
  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. }