Skip to content

Commit 0c181b0

Browse files
committed
tests: add variadic parameter tests
Ref: 20Tauri/DoxyDoxygen#135 Ref: 20Tauri/DoxyDoxygen#135 (comment)
1 parent 0a217cf commit 0c181b0

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

tests/Parser/NodeVisitorTest.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,34 @@ public function testUpdateMethodParametersFromTags(): void
367367
);
368368
}
369369

370+
/**
371+
* @see NodeVisitor::updateMethodParametersFromTags
372+
* @see https://github.com/20Tauri/DoxyDoxygen/issues/135#issuecomment-512090231
373+
*/
374+
public function testUpdateMethodParametersFromTagsVariadic(): void
375+
{
376+
$docBlockParser = new DocBlockParser();
377+
$docBlockNode = $docBlockParser->parse(
378+
'/**' . "\n"
379+
. '* @param FooBar|baz|string ...$args' . "\n"
380+
. '**/' . "\n"
381+
);
382+
$parserContext = new ParserContext(new TrueFilter(), new DocBlockParser(), new Standard());
383+
$visitor = new NodeVisitor($parserContext);
384+
$function = new FunctionReflection('fun1', 0);
385+
386+
$param1 = (new ParameterReflection('args', 0));
387+
$function->addParameter($param1);
388+
389+
$this->assertSame(
390+
[],
391+
$this->callMethod($visitor, 'updateMethodParametersFromTags', [
392+
$function,
393+
$docBlockNode->getTag('param')
394+
])
395+
);
396+
}
397+
370398
/**
371399
* @see NodeVisitor::updateMethodParametersFromTags
372400
* @requires PHP 7.2
@@ -471,4 +499,32 @@ public function testAddTagFromCommentToMethodInvalidHint(): void
471499
$errors
472500
);
473501
}
502+
503+
/**
504+
* @see NodeVisitor::addTagFromCommentToMethod
505+
*/
506+
public function testAddTagFromCommentToMethodHintVariadic(): void
507+
{
508+
$docBlockParser = new DocBlockParser();
509+
$docBlockNode = $docBlockParser->parse(
510+
'/**' . "\n"
511+
. '* @var FooBar|baz|string ...$args' . "\n"
512+
. '**/' . "\n"
513+
);
514+
$parserContext = new ParserContext(new TrueFilter(), new DocBlockParser(), new Standard());
515+
$visitor = new NodeVisitor($parserContext);
516+
$property = new PropertyReflection('args', 0);
517+
518+
$errors = [];
519+
$this->callMethod($visitor, 'addTagFromCommentToMethod', [
520+
'var',
521+
$docBlockNode,
522+
$property,
523+
&$errors
524+
]);
525+
$this->assertSame(
526+
[],
527+
$errors
528+
);
529+
}
474530
}

0 commit comments

Comments
 (0)