AugmentOperationTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * @license Apache 2.0
  4. */
  5. namespace Swaggertests;
  6. use Swagger\Processors\AugmentOperations;
  7. use Swagger\StaticAnalyser;
  8. class AugmentOperationTest extends SwaggerTestCase
  9. {
  10. public function testAugmentOperation()
  11. {
  12. $analyser = new StaticAnalyser();
  13. $analysis = $analyser->fromFile(__DIR__.'/Fixtures/UsingPhpDoc.php');
  14. $analysis->process([
  15. new AugmentOperations(),
  16. ]);
  17. $operations = $analysis->getAnnotationsOfType('\Swagger\Annotations\Operation');
  18. $this->assertSame('api/test1', $operations[0]->path);
  19. $this->assertSame('Example summary', $operations[0]->summary, 'Operation summary should be taken from phpDoc');
  20. $this->assertSame("Example description...\nMore description...", $operations[0]->description, 'Operation description should be taken from phpDoc');
  21. $this->assertSame('api/test2', $operations[1]->path);
  22. $this->assertSame('Example summary', $operations[1]->summary, 'Operation summary should be taken from phpDoc');
  23. $this->assertNull($operations[1]->description, 'This operation only has summary in the phpDoc, no description');
  24. }
  25. }