55namespace PhpMyAdmin \Tests \Advisory ;
66
77use PhpMyAdmin \Advisory \Advisor ;
8+ use PhpMyAdmin \Advisory \Rules ;
89use PhpMyAdmin \Tests \AbstractTestCase ;
910use PHPUnit \Framework \Attributes \CoversClass ;
1011use PHPUnit \Framework \Attributes \DataProvider ;
1112use Symfony \Component \ExpressionLanguage \ExpressionLanguage ;
1213
14+ /** @psalm-import-type RuleType from Rules */
1315#[CoversClass(Advisor::class)]
1416class AdvisorTest extends AbstractTestCase
1517{
@@ -54,6 +56,8 @@ public static function advisorTimes(): array
5456 * @param mixed[] $rule Rule to test
5557 * @param mixed[] $expected Expected rendered rule in fired/errors list
5658 * @param string|null $error Expected error string (null if none error expected)
59+ * @psalm-param RuleType $rule
60+ * @psalm-param RuleType|array<empty> $expected
5761 */
5862 #[DataProvider('rulesProvider ' )]
5963 public function testAddRule (array $ rule , array $ expected , string |null $ error ): void
@@ -75,7 +79,10 @@ public function testAddRule(array $rule, array $expected, string|null $error): v
7579 $ this ->assertEquals ([$ expected ], $ runResult ['fired ' ]);
7680 }
7781
78- /** @return mixed[][] */
82+ /**
83+ * @return mixed[][]
84+ * @psalm-return array<int, array{RuleType, RuleType|array<empty>, string|null}>
85+ */
7986 public static function rulesProvider (): array
8087 {
8188 return [
@@ -86,13 +93,17 @@ public static function rulesProvider(): array
8693 'name ' => 'Basic ' ,
8794 'issue ' => 'issue ' ,
8895 'recommendation ' => 'Recommend ' ,
96+ 'formula ' => 'formula ' ,
97+ 'test ' => 'test ' ,
8998 ],
9099 [
91100 'justification ' => 'foo ' ,
92101 'id ' => 'Basic ' ,
93102 'name ' => 'Basic ' ,
94103 'issue ' => 'issue ' ,
95104 'recommendation ' => 'Recommend ' ,
105+ 'formula ' => 'formula ' ,
106+ 'test ' => 'test ' ,
96107 ],
97108 null ,
98109 ],
@@ -103,14 +114,18 @@ public static function rulesProvider(): array
103114 'name ' => 'Variable ' ,
104115 'issue ' => 'issue ' ,
105116 'recommendation ' => 'Recommend {status_var} ' ,
117+ 'formula ' => 'formula ' ,
118+ 'test ' => 'test ' ,
106119 ],
107120 [
108121 'justification ' => 'foo ' ,
109122 'id ' => 'Variable ' ,
110123 'name ' => 'Variable ' ,
111124 'issue ' => 'issue ' ,
112- 'recommendation ' => 'Recommend <a href="index.php?route=/server/variables& ' .
113- 'filter=status_var&lang=en">status_var</a> ' ,
125+ 'recommendation ' => 'Recommend <a href="index.php?route=/server/variables& '
126+ . 'filter=status_var&lang=en">status_var</a> ' ,
127+ 'formula ' => 'formula ' ,
128+ 'test ' => 'test ' ,
114129 ],
115130 null ,
116131 ],
@@ -122,6 +137,8 @@ public static function rulesProvider(): array
122137 'name ' => 'Format ' ,
123138 'issue ' => 'issue ' ,
124139 'recommendation ' => 'Recommend ' ,
140+ 'formula ' => 'formula ' ,
141+ 'test ' => 'test ' ,
125142 ],
126143 [
127144 'justification ' => '0 foo ' ,
@@ -130,6 +147,8 @@ public static function rulesProvider(): array
130147 'name ' => 'Format ' ,
131148 'issue ' => 'issue ' ,
132149 'recommendation ' => 'Recommend ' ,
150+ 'formula ' => 'formula ' ,
151+ 'test ' => 'test ' ,
133152 ],
134153 null ,
135154 ],
@@ -141,6 +160,8 @@ public static function rulesProvider(): array
141160 'name ' => 'Percent ' ,
142161 'issue ' => 'issue ' ,
143162 'recommendation ' => 'Recommend ' ,
163+ 'formula ' => 'formula ' ,
164+ 'test ' => 'test ' ,
144165 ],
145166 [
146167 'justification ' => '0% foo ' ,
@@ -149,6 +170,8 @@ public static function rulesProvider(): array
149170 'name ' => 'Percent ' ,
150171 'issue ' => 'issue ' ,
151172 'recommendation ' => 'Recommend ' ,
173+ 'formula ' => 'formula ' ,
174+ 'test ' => 'test ' ,
152175 ],
153176 null ,
154177 ],
@@ -160,6 +183,8 @@ public static function rulesProvider(): array
160183 'name ' => 'Double ' ,
161184 'issue ' => 'issue ' ,
162185 'recommendation ' => 'Recommend ' ,
186+ 'formula ' => 'formula ' ,
187+ 'test ' => 'test ' ,
163188 ],
164189 [
165190 'justification ' => '0% 0 foo ' ,
@@ -168,6 +193,8 @@ public static function rulesProvider(): array
168193 'name ' => 'Double ' ,
169194 'issue ' => 'issue ' ,
170195 'recommendation ' => 'Recommend ' ,
196+ 'formula ' => 'formula ' ,
197+ 'test ' => 'test ' ,
171198 ],
172199 null ,
173200 ],
@@ -178,23 +205,30 @@ public static function rulesProvider(): array
178205 'name ' => 'Quotes ' ,
179206 'issue ' => 'issue ' ,
180207 'recommendation ' => 'Recommend" \'' ,
208+ 'formula ' => 'formula ' ,
209+ 'test ' => 'test ' ,
181210 ],
182211 [
183212 'justification ' => '" \'foo ' ,
184213 'id ' => 'Quotes ' ,
185214 'name ' => 'Quotes ' ,
186215 'issue ' => 'issue ' ,
187216 'recommendation ' => 'Recommend" \'' ,
217+ 'formula ' => 'formula ' ,
218+ 'test ' => 'test ' ,
188219 ],
189220 null ,
190221 ],
191222 [
192223 [
224+ 'id ' => 'Failure ' ,
193225 'justification ' => 'foo ' ,
194226 'justification_formula ' => 'fsafdsa ' ,
195227 'name ' => 'Failure ' ,
196228 'issue ' => 'issue ' ,
197229 'recommendation ' => 'Recommend ' ,
230+ 'formula ' => 'formula ' ,
231+ 'test ' => 'test ' ,
198232 ],
199233 [],
200234 'Failed formatting string for rule \'Failure \'. ' .
@@ -209,6 +243,8 @@ public static function rulesProvider(): array
209243 'name ' => 'Distribution ' ,
210244 'issue ' => 'official MySQL binaries. ' ,
211245 'recommendation ' => 'See <a href="https://example.com/">web</a> ' ,
246+ 'formula ' => 'formula ' ,
247+ 'test ' => 'test ' ,
212248 ],
213249 [
214250 'justification ' => 'Version string (0) ' ,
@@ -218,6 +254,8 @@ public static function rulesProvider(): array
218254 'recommendation ' => 'See <a href="index.php?route=/url&url=https%3A%2F%2F ' .
219255 'example.com%2F" target="_blank" rel="noopener noreferrer">web</a> ' ,
220256 'id ' => 'Distribution ' ,
257+ 'formula ' => 'formula ' ,
258+ 'test ' => 'test ' ,
221259 ],
222260 null ,
223261 ],
@@ -229,6 +267,8 @@ public static function rulesProvider(): array
229267 'name ' => 'Distribution ' ,
230268 'issue ' => 'official MySQL binaries. ' ,
231269 'recommendation ' => 'See <a href="https://example.com/">web</a> ' ,
270+ 'formula ' => 'formula ' ,
271+ 'test ' => 'test ' ,
232272 ],
233273 [
234274 'justification ' => 'Timestamp (15 days, 22 hours, 30 minutes and 27 seconds) ' ,
@@ -238,6 +278,8 @@ public static function rulesProvider(): array
238278 'recommendation ' => 'See <a href="index.php?route=/url&url=https%3A%2F%2F ' .
239279 'example.com%2F" target="_blank" rel="noopener noreferrer">web</a> ' ,
240280 'id ' => 'Distribution ' ,
281+ 'formula ' => 'formula ' ,
282+ 'test ' => 'test ' ,
241283 ],
242284 null ,
243285 ],
@@ -250,6 +292,8 @@ public static function rulesProvider(): array
250292 'issue ' => 'official MySQL binaries. ' ,
251293 'recommendation ' => 'See <a href="https://example.com/">web</a> and '
252294 . ' <a href="https://example.com/">web2</a> ' ,
295+ 'formula ' => 'formula ' ,
296+ 'test ' => 'test ' ,
253297 ],
254298 [
255299 'justification ' => 'Memory: 0.95 MiB ' ,
@@ -261,6 +305,8 @@ public static function rulesProvider(): array
261305 . ' and <a href="index.php?route=/url&url=https%3A%2F%2Fexample.com%2F" target="_blank" '
262306 . ' rel="noopener noreferrer">web2</a> ' ,
263307 'id ' => 'Distribution ' ,
308+ 'formula ' => 'formula ' ,
309+ 'test ' => 'test ' ,
264310 ],
265311 null ,
266312 ],
@@ -273,6 +319,8 @@ public static function rulesProvider(): array
273319 'issue ' => '{long_query_time} is set to 10 seconds or more ' ,
274320 'recommendation ' => 'See <a href= \'https://example.com/ \'>web</a> and '
275321 . ' <a href= \'https://example.com/ \'>web2</a> ' ,
322+ 'formula ' => 'formula ' ,
323+ 'test ' => 'test ' ,
276324 ],
277325 [
278326 'justification ' => 'Time: 1.2 per minute ' ,
@@ -285,6 +333,8 @@ public static function rulesProvider(): array
285333 . ' and <a href="index.php?route=/url&url=https%3A%2F%2Fexample.com%2F" target="_blank" '
286334 . ' rel="noopener noreferrer">web2</a> ' ,
287335 'id ' => 'Distribution ' ,
336+ 'formula ' => 'formula ' ,
337+ 'test ' => 'test ' ,
288338 ],
289339 null ,
290340 ],
0 commit comments