Dashboard sipadu mbip
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

MethodNotAllowedHttpExceptionTest.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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(['GET', 'PUT']);
  9. $this->assertSame(['Allow' => 'GET, PUT'], $exception->getHeaders());
  10. }
  11. public function testWithHeaderConstruct()
  12. {
  13. $headers = [
  14. 'Cache-Control' => 'public, s-maxage=1200',
  15. ];
  16. $exception = new MethodNotAllowedHttpException(['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(['GET']);
  26. $exception->setHeaders($headers);
  27. $this->assertSame($headers, $exception->getHeaders());
  28. }
  29. protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
  30. {
  31. return new MethodNotAllowedHttpException(['get'], $message, $previous, $code, $headers);
  32. }
  33. }