NestedPropertyTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * @license Apache 2.0
  4. */
  5. namespace SwaggerTests;
  6. use Swagger\Processors\AugmentDefinitions;
  7. use Swagger\Processors\AugmentProperties;
  8. use Swagger\Processors\MergeIntoSwagger;
  9. use Swagger\StaticAnalyser;
  10. class NestedPropertyTest extends SwaggerTestCase
  11. {
  12. public function testNestedProperties()
  13. {
  14. $analyser = new StaticAnalyser();
  15. $analysis = $analyser->fromFile(__DIR__ . '/Fixtures/NestedProperty.php');
  16. $analysis->process(new MergeIntoSwagger());
  17. $analysis->process(new AugmentDefinitions());
  18. $analysis->process(new AugmentProperties());
  19. $this->assertCount(1, $analysis->swagger->definitions);
  20. $definition = $analysis->swagger->definitions[0];
  21. $this->assertEquals('NestedProperty', $definition->definition);
  22. $this->assertCount(1, $definition->properties);
  23. $parentProperty = $definition->properties[0];
  24. $this->assertEquals('parentProperty', $parentProperty->property);
  25. $this->assertCount(1, $parentProperty->properties);
  26. $babyProperty = $parentProperty->properties[0];
  27. $this->assertEquals('babyProperty', $babyProperty->property);
  28. $this->assertCount(1, $babyProperty->properties);
  29. $theBabyOfBaby = $babyProperty->properties[0];
  30. $this->assertEquals('theBabyOfBaby', $theBabyOfBaby->property);
  31. $this->assertCount(1, $theBabyOfBaby->properties);
  32. // verbose not-recommend notations
  33. $theBabyOfBabyBaby = $theBabyOfBaby->properties[0];
  34. $this->assertEquals('theBabyOfBabyBaby', $theBabyOfBabyBaby->property);
  35. $this->assertNull($theBabyOfBabyBaby->properties);
  36. }
  37. }