1616use phpDocumentor \Reflection \DocBlock \Description ;
1717use phpDocumentor \Reflection \DocBlock \Tags \Param ;
1818use phpDocumentor \Reflection \Types \Context ;
19+ use phpDocumentor \Reflection \Types \Integer ;
20+ use phpDocumentor \Reflection \Types \Mixed_ ;
1921use phpDocumentor \Reflection \Types \String_ ;
2022
2123final class ParamFactoryTest extends TagFactoryTestCase
@@ -24,23 +26,77 @@ final class ParamFactoryTest extends TagFactoryTestCase
2426 * @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::__construct
2527 * @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::create
2628 * @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::supports
29+ * @dataProvider paramInputProvider
2730 */
28- public function testParamIsCreated (): void
31+ public function testParamIsCreated (string $ input , Param $ expected ): void
2932 {
30- $ ast = $ this ->parseTag (' @param string $var ' );
33+ $ ast = $ this ->parseTag ($ input );
3134 $ factory = new ParamFactory ($ this ->giveTypeResolver (), $ this ->givenDescriptionFactory ());
3235 $ context = new Context ('global ' );
3336
3437 self ::assertTrue ($ factory ->supports ($ ast , $ context ));
3538 self ::assertEquals (
36- new Param (
37- 'var ' ,
38- new String_ (),
39- false ,
40- new Description ('' ),
41- false
42- ),
39+ $ expected ,
4340 $ factory ->create ($ ast , $ context )
4441 );
4542 }
43+
44+ /**
45+ * @return array<array-key, string|Param>
46+ */
47+ public function paramInputProvider (): array
48+ {
49+ return [
50+ [
51+ '@param string $var ' ,
52+ new Param (
53+ 'var ' ,
54+ new String_ (),
55+ false ,
56+ new Description ('' ),
57+ false
58+ ),
59+ ],
60+ [
61+ '@param $param8 Description 4 ' ,
62+ new Param (
63+ 'param8 ' ,
64+ new Mixed_ (),
65+ false ,
66+ new Description ('Description 4 ' ),
67+ false
68+ ),
69+ ],
70+ [
71+ '@param $param9 ' ,
72+ new Param (
73+ 'param9 ' ,
74+ new Mixed_ (),
75+ false ,
76+ new Description ('' ),
77+ false
78+ ),
79+ ],
80+ [
81+ '@param int My Description ' ,
82+ new Param (
83+ null ,
84+ new Integer (),
85+ false ,
86+ new Description ('My Description ' ),
87+ false
88+ ),
89+ ],
90+ [
91+ '@param foo ' ,
92+ new Param (
93+ null ,
94+ new Mixed_ (),
95+ false ,
96+ new Description ('' ),
97+ false
98+ ),
99+ ],
100+ ];
101+ }
46102}
0 commit comments