1<?php 2 3namespace dokuwiki\test\Remote\OpenApiDoc; 4 5use dokuwiki\Remote\OpenApiDoc\DocBlockMethod; 6 7class DocBlockMethodTest extends \DokuWikiTest { 8 9 10 /** 11 * This is a test 12 * 13 * With more information 14 * in several lines 15 * @param string $foo First variable 16 * @param int $bar 17 * @param string[] $baz 18 * @something else 19 * @something other 20 * @another tag 21 * @return string The return 22 */ 23 public function dummyMethod1($foo, $bar, $baz=['a default']) 24 { 25 return 'dummy'; 26 } 27 28 public function testMethod() 29 { 30 $reflect = new \ReflectionMethod($this, 'dummyMethod1'); 31 $doc = new DocBlockMethod($reflect); 32 33 $this->assertEquals('This is a test', $doc->getSummary()); 34 $this->assertEquals("With more information\nin several lines", $doc->getDescription()); 35 36 $this->assertEquals( 37 [ 38 'foo' => [ 39 'type' => 'string', 40 'description' => 'First variable', 41 'optional' => false, 42 ], 43 'bar' => [ 44 'type' => 'int', 45 'description' => '', 46 'optional' => false, 47 ], 48 'baz' => [ 49 'type' => 'string[]', 50 'description' => '', 51 'optional' => true, 52 'default' => ['a default'], 53 ], 54 ], 55 $doc->getTag('param') 56 ); 57 58 $this->assertEquals( 59 [ 60 'type' => 'string', 61 'description' => 'The return' 62 ], 63 $doc->getTag('return') 64 ); 65 66 $this->assertEquals( 67 [ 68 'else', 69 'other', 70 ], 71 $doc->getTag('something') 72 ); 73 74 $this->assertEquals( 75 [ 76 'tag', 77 ], 78 $doc->getTag('another') 79 ); 80 } 81} 82