AugmentDefinitionsTest.php 973 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * @license Apache 2.0
  4. */
  5. namespace SwaggerTests;
  6. use Swagger\Processors\AugmentDefinitions;
  7. use Swagger\Processors\MergeIntoSwagger;
  8. use Swagger\StaticAnalyser;
  9. class AugmentDefinitionsTest extends SwaggerTestCase
  10. {
  11. public function testAugmentDefinitions()
  12. {
  13. $analyser = new StaticAnalyser();
  14. $analysis = $analyser->fromFile(__DIR__ . '/Fixtures/Customer.php');
  15. $analysis->process(new MergeIntoSwagger());
  16. $this->assertCount(1, $analysis->swagger->definitions);
  17. $customer = $analysis->swagger->definitions[0];
  18. $this->assertNull($customer->properties, 'Sanity check. @SWG\Property\'s not yet merged ');
  19. $analysis->process(new AugmentDefinitions());
  20. $this->assertSame('Customer', $customer->definition, '@SWG\Definition()->definition based on classname');
  21. $this->assertCount(5, $customer->properties, '@SWG\Property()s are merged into the @SWG\Definition of the class');
  22. }
  23. }