4
0

ExamplesTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php declare(strict_types=1);
  2. /**
  3. * @license Apache 2.0
  4. */
  5. namespace OpenApiTests;
  6. class ExamplesTest extends OpenApiTestCase
  7. {
  8. /**
  9. * Test the processed Examples against json files in ExamplesOutput.
  10. *
  11. * @dataProvider getExamples
  12. *
  13. * @param string $example Example path
  14. * @param string $output Expected output (path to a json file)
  15. */
  16. public function testExample($example, $output)
  17. {
  18. $openapi = \OpenApi\scan(__DIR__.'/../Examples/'.$example);
  19. $this->assertOpenApiEqualsFile(__DIR__.'/ExamplesOutput/'.$output, $openapi);
  20. }
  21. /**
  22. * dataProvider for testExample
  23. *
  24. * @return array
  25. */
  26. public function getExamples()
  27. {
  28. return [
  29. ['misc', 'misc.json'],
  30. ['openapi-spec', 'openapi-spec.json'],
  31. ['petstore.swagger.io', 'petstore.swagger.io.json'],
  32. ['petstore-3.0', 'petstore-3.0.json'],
  33. ['swagger-spec/petstore', 'petstore.json'],
  34. ['swagger-spec/petstore-simple', 'petstore-simple.json'],
  35. ['swagger-spec/petstore-with-external-docs', 'petstore-with-external-docs.json'],
  36. ['using-refs', 'using-refs.json'],
  37. ['example-object', 'example-object.json'],
  38. ];
  39. }
  40. }