4
0

ResponseTest.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php declare(strict_types=1);
  2. /**
  3. * @license Apache 2.0
  4. */
  5. namespace OpenApiTests;
  6. class ResponseTest extends OpenApiTestCase
  7. {
  8. public function testMisspelledDefault()
  9. {
  10. $this->validateMisspelledAnnotation("Default");
  11. }
  12. public function testMisspelledRangeDefinition()
  13. {
  14. $this->validateMisspelledAnnotation("5xX");
  15. }
  16. public function testWrongRangeDefinition()
  17. {
  18. $this->validateMisspelledAnnotation("6XX");
  19. }
  20. protected function validateMisspelledAnnotation(string $response = "")
  21. {
  22. $annotations = $this->parseComment(
  23. '@OA\Get(@OA\Response(response="' . $response . '", description="description"))'
  24. );
  25. /**
  26. * @see Annotations/Operation.php:187
  27. */
  28. $this->assertOpenApiLogEntryStartsWith(
  29. 'Invalid value "'.$response.'" for @OA\Response()->response, expecting "default"'
  30. . ', a HTTP Status Code or HTTP '
  31. );
  32. $annotations[0]->validate();
  33. }
  34. }