16
16
use phpDocumentor \Reflection \DocBlock \Description ;
17
17
use phpDocumentor \Reflection \DocBlock \Tags \Param ;
18
18
use phpDocumentor \Reflection \Types \Context ;
19
+ use phpDocumentor \Reflection \Types \Integer ;
20
+ use phpDocumentor \Reflection \Types \Mixed_ ;
19
21
use phpDocumentor \Reflection \Types \String_ ;
20
22
21
23
final class ParamFactoryTest extends TagFactoryTestCase
@@ -24,23 +26,77 @@ final class ParamFactoryTest extends TagFactoryTestCase
24
26
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::__construct
25
27
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::create
26
28
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::supports
29
+ * @dataProvider paramInputProvider
27
30
*/
28
- public function testParamIsCreated (): void
31
+ public function testParamIsCreated (string $ input , Param $ expected ): void
29
32
{
30
- $ ast = $ this ->parseTag (' @param string $var ' );
33
+ $ ast = $ this ->parseTag ($ input );
31
34
$ factory = new ParamFactory ($ this ->giveTypeResolver (), $ this ->givenDescriptionFactory ());
32
35
$ context = new Context ('global ' );
33
36
34
37
self ::assertTrue ($ factory ->supports ($ ast , $ context ));
35
38
self ::assertEquals (
36
- new Param (
37
- 'var ' ,
38
- new String_ (),
39
- false ,
40
- new Description ('' ),
41
- false
42
- ),
39
+ $ expected ,
43
40
$ factory ->create ($ ast , $ context )
44
41
);
45
42
}
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
+ }
46
102
}
0 commit comments