Debian Codegraph @

tests/phpunit/unit/maintenance/MWDoxygenFilterTest.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\Maintenance\MWDoxygenFilter;
4
5 /**
6 * @covers \MediaWiki\Namespace\MWDoxygenFilter
7 */
8 class MWDoxygenFilterTest extends \PHPUnit\Framework\TestCase {
9
10 public static function provideFilter() {
11 yield 'No @var' => [
12 <<<'CODE'
13 <?php class MyClass {
14 /** Some Words here */
15 protected $name;
16 }
17 CODE
18 ];
19
20 yield 'One-line var with type' => [
21 <<<'CODE'
22 <?php class MyClass {
23 /** @var SomeType */
24 protected $name;
25 }
26 CODE
27 , <<<'CODE'
28 <?php class MyClass {
29 /** */
30 protected SomeType $name;
31 }
32 CODE
33 ];
34
35 yield 'One-line var with type and description' => [
36 <<<'CODE'
37 <?php class MyClass {
38 /** @var SomeType Some description */
39 protected $name;
40 }
41 CODE
42 , <<<'CODE'
43 <?php class MyClass {
44 /** Some description */
45 protected SomeType $name;
46 }
47 CODE
48 ];
49
50 yield 'One-line var with type and description that starts like a variable name' => [
51 <<<'CODE'
52 <?php class MyClass {
53 /** @var array $_GET data from some thing */
54 protected $name;
55 }
56 CODE
57 , <<<'CODE'
58 <?php class MyClass {
59 /** $_GET data from some thing */
60 protected array $name;
61 }
62 CODE
63 ];
64
65 yield 'One-line var with type, name, and description' => [
66 // In this full form, Doxygen understands it just fine.
67 // No changes made.
68 <<<'CODE'
69 <?php class MyClass {
70 /** @var SomeType $name Some description */
71 protected $name;
72 }
73 CODE
74 ];
75
76 yield 'Multi-line var with type' => [
77 <<<'CODE'
78 <?php class MyClass {
79 /**
80 * @var SomeType
81 */
82 protected $name;
83 }
84 CODE
85 , <<<'CODE'
86 <?php class MyClass {
87 /**
88 *
89 */
90 protected SomeType $name;
91 }
92 CODE
93 ];
94
95 yield 'Multi-line var with type and description' => [
96 <<<'CODE'
97 <?php class MyClass {
98 /**
99 * Some description
100 * @var SomeType
101 */
102 protected $name;
103 }
104 CODE
105 , <<<'CODE'
106 <?php class MyClass {
107 /**
108 * Some description
109 *
110 */
111 protected SomeType $name;
112 }
113 CODE
114 ];
115
116 yield 'Multi-line var with type, name, and description' => [
117 <<<'CODE'
118 <?php class MyClass {
119 /**
120 * Some description
121 * @var SomeType $name
122 */
123 protected $name;
124 }
125 CODE
126 , <<<'CODE'
127 <?php class MyClass {
128 /**
129 * Some description
130 * @var SomeType $name
131 */
132 protected $name;
133 }
134 CODE
135 ];
136 }
137
138 /**
139 * @dataProvider provideFilter
140 */
141 public function testFilter( $source, $expected = null ) {
142 $this->assertSame(
143 $expected ?? $source,
144 MWDoxygenFilter::filter( $source ),
145 'Source code'
146 );
147 }
148 }