MergeIntoComponentsTest.php 897 B

123456789101112131415161718192021222324252627282930313233
  1. <?php declare(strict_types=1);
  2. /**
  3. * @license Apache 2.0
  4. */
  5. namespace OpenApiTests;
  6. use OpenApi\Analysis;
  7. use OpenApi\Annotations\OpenApi;
  8. use OpenApi\Annotations\Response;
  9. use OpenApi\Processors\MergeIntoComponents;
  10. use const OpenApi\UNDEFINED;
  11. class MergeIntoComponentsTest extends OpenApiTestCase
  12. {
  13. public function testProcessor()
  14. {
  15. $openapi = new OpenApi([]);
  16. $response = new Response(['response' => '2xx']);
  17. $analysis = new Analysis(
  18. [
  19. $openapi,
  20. $response,
  21. ]
  22. );
  23. $this->assertSame(UNDEFINED, $openapi->components);
  24. $analysis->process(new MergeIntoComponents());
  25. $this->assertCount(1, $openapi->components->responses);
  26. $this->assertSame($response, $openapi->components->responses[0]);
  27. $this->assertCount(0, $analysis->unmerged()->annotations);
  28. }
  29. }