HandleReferencesTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * @license Apache 2.0
  4. */
  5. namespace SwaggerTests;
  6. use Swagger\Annotations\Schema;
  7. class HandleReferencesTest extends SwaggerTestCase
  8. {
  9. public function testRef()
  10. {
  11. $swagger = \Swagger\scan(__DIR__ . '/Fixtures/DynamicReference.php');
  12. /** @var Schema $schema */
  13. $schema = $swagger->paths[0]->post->responses[0]->schema;
  14. $props = $schema->properties;
  15. $this->assertEquals('success', $props[0]->property, 'The @SWG\Schema should contain properties from the extended @SWG\Response');
  16. $this->assertEquals('data', $props[1]->property, 'The @SWG\Schema should contain properties from the extended @SWG\Response');
  17. $this->assertEquals('#/definitions/Product', $props[1]->ref, 'The @SWG\Schema should contain the original property from the child. This property will override the parent property from @SWG\Response');
  18. $this->assertEquals('errors', $props[2]->property, 'The @SWG\Schema should contain properties from the extended @SWG\Response');
  19. $this->assertEquals('token', $props[3]->property, 'The @SWG\Schema should contain properties from the extended @SWG\Response');
  20. $this->assertEquals('status', $props[4]->property, 'The @SWG\Schema should contain properties from the extended @SWG\Response');
  21. $this->assertEquals('test', $props[5]->property, 'The @SWG\Schema should contain properties from the extended @SWG\Response');
  22. $this->assertEquals('string', $props[5]->type, 'The @SWG\Schema should contain properties from the extended @SWG\Response');
  23. $this->assertEquals('The status of a product', $props[5]->description, 'The @SWG\Schema should contain properties from the extended @SWG\Response');
  24. }
  25. }