parse(); $this->assertSame("Get all data\n", $doc->getSummary()); } public function testSimpleSummaryMultiLine() { $doc = new LuMethodDocParser("/** * Get all data * Using the database */"); $doc->parse(); $this->assertSame("Get all data\nUsing the database\n", $doc->getSummary()); } public function testSimpleParam() { $doc = new LuMethodDocParser('/** * Get all data * @param $myvar MyType some doc * @param MyType $myvar2 some other doc */'); $doc->parse(); $this->assertSame("Get all data\n", $doc->getSummary()); $params = []; foreach ($doc->getParams() as $param) { $params[] = $param->jsonSerialize(); } $expectedParams = [ ["notNull" => true, "summary" => "some doc\n", "type" => "MyType", "name" => 'myvar', "constraints" => []], ["notNull" => true, "summary" => "some other doc\n", "type" => "MyType", "name" => 'myvar2', "constraints" => []] ]; $this->assertSame($expectedParams, $params); } public function testSimpleParamMultiLine() { $doc = new LuMethodDocParser('/** * Get all data * @param $myvar MyType some doc * @param MyType $myvar2 some other doc * on another line */'); $doc->parse(); $this->assertSame("Get all data\n", $doc->getSummary()); $params = []; foreach ($doc->getParams() as $name => $param) { $params[$name] = $param->jsonSerialize(); } $expectedParams = [ 'myvar' => ["notNull" => true, "summary" => "some doc\n", "type" => "MyType", "name" => 'myvar', "constraints" => []], 'myvar2' => ["notNull" => true, "summary" => "some other doc\non another line\n", "type" => "MyType", "name" => 'myvar2', "constraints" => []] ]; $this->assertSame($expectedParams, $params); } public function testAll() { $doc = new LuMethodDocParser('/** * Get all data * On another line * @param $myvar MyType some doc * Too much doc * @param MyType $myvar2 some other doc * on another line * @nullable * @min 42 * @max 42 * @between 0 42 * @another 1 2 42.42 true false "a string" \'string\' null * and another * @return AnotherType */'); $doc->parse(); $this->assertSame("Get all data\nOn another line\n", $doc->getSummary()); $this->assertSame("AnotherType", $doc->getReturnType()); $params = []; foreach ($doc->getParams() as $name => $param) { $params[$name] = $param->jsonSerialize(); } $expectedParams = [ 'myvar' => ["notNull" => true, "summary" => "some doc\nToo much doc\n", "type" => "MyType", "name" => 'myvar', "constraints" => []], 'myvar2' => ["notNull" => false, "summary" => "some other doc\non another line\nand another\n", "type" => "MyType", "name" => 'myvar2', "constraints" => [ ["method" => "min", "arguments" => [42]], ["method" => "max", "arguments" => [42]], ["method" => "between", "arguments" => [0, 42]], ["method" => "another", "arguments" => [1, 2, 42.42, true, false, "a string", "string", null]] ] ] ]; $this->assertSame($expectedParams, $params); } }