11
11
12
12
namespace Symfony \Component \ExpressionLanguage \Tests ;
13
13
14
+ use PHPUnit \Framework \Attributes \DataProvider ;
14
15
use PHPUnit \Framework \TestCase ;
15
16
use Psr \Cache \CacheItemInterface ;
16
17
use Psr \Cache \CacheItemPoolInterface ;
@@ -71,9 +72,7 @@ public function testCachedParse()
71
72
$ this ->assertSame ($ savedParsedExpression , $ parsedExpression );
72
73
}
73
74
74
- /**
75
- * @dataProvider basicPhpFunctionProvider
76
- */
75
+ #[DataProvider('basicPhpFunctionProvider ' )]
77
76
public function testBasicPhpFunction ($ expression , $ expected , $ compiled )
78
77
{
79
78
$ expressionLanguage = new ExpressionLanguage ();
@@ -137,9 +136,7 @@ public function testCompiledEnumFunctionWithBackedEnum()
137
136
$ this ->assertSame (FooBackedEnum::Bar, $ result );
138
137
}
139
138
140
- /**
141
- * @dataProvider providerTestCases
142
- */
139
+ #[DataProvider('providerTestCases ' )]
143
140
public function testProviders (iterable $ providers )
144
141
{
145
142
$ expressionLanguage = new ExpressionLanguage (null , $ providers );
@@ -161,18 +158,14 @@ public static function providerTestCases(): iterable
161
158
})()];
162
159
}
163
160
164
- /**
165
- * @dataProvider shortCircuitProviderEvaluate
166
- */
161
+ #[DataProvider('shortCircuitProviderEvaluate ' )]
167
162
public function testShortCircuitOperatorsEvaluate ($ expression , array $ values , $ expected )
168
163
{
169
164
$ expressionLanguage = new ExpressionLanguage ();
170
165
$ this ->assertSame ($ expected , $ expressionLanguage ->evaluate ($ expression , $ values ));
171
166
}
172
167
173
- /**
174
- * @dataProvider shortCircuitProviderCompile
175
- */
168
+ #[DataProvider('shortCircuitProviderCompile ' )]
176
169
public function testShortCircuitOperatorsCompile ($ expression , array $ names , $ expected )
177
170
{
178
171
$ result = null ;
@@ -304,9 +297,7 @@ public function testOperatorCollisions()
304
297
$ this ->assertTrue ($ result );
305
298
}
306
299
307
- /**
308
- * @dataProvider getRegisterCallbacks
309
- */
300
+ #[DataProvider('getRegisterCallbacks ' )]
310
301
public function testRegisterAfterParse ($ registerCallback )
311
302
{
312
303
$ this ->expectException (\LogicException::class);
@@ -315,9 +306,7 @@ public function testRegisterAfterParse($registerCallback)
315
306
$ registerCallback ($ el );
316
307
}
317
308
318
- /**
319
- * @dataProvider getRegisterCallbacks
320
- */
309
+ #[DataProvider('getRegisterCallbacks ' )]
321
310
public function testRegisterAfterEval ($ registerCallback )
322
311
{
323
312
$ this ->expectException (\LogicException::class);
@@ -326,18 +315,14 @@ public function testRegisterAfterEval($registerCallback)
326
315
$ registerCallback ($ el );
327
316
}
328
317
329
- /**
330
- * @dataProvider provideNullSafe
331
- */
318
+ #[DataProvider('provideNullSafe ' )]
332
319
public function testNullSafeEvaluate ($ expression , $ foo )
333
320
{
334
321
$ expressionLanguage = new ExpressionLanguage ();
335
322
$ this ->assertNull ($ expressionLanguage ->evaluate ($ expression , ['foo ' => $ foo ]));
336
323
}
337
324
338
- /**
339
- * @dataProvider provideNullSafe
340
- */
325
+ #[DataProvider('provideNullSafe ' )]
341
326
public function testNullSafeCompile ($ expression , $ foo )
342
327
{
343
328
$ expressionLanguage = new ExpressionLanguage ();
@@ -374,9 +359,7 @@ public function bar()
374
359
yield ['foo?.bar()["baz"]["qux"].quux() ' , null ];
375
360
}
376
361
377
- /**
378
- * @dataProvider provideInvalidNullSafe
379
- */
362
+ #[DataProvider('provideInvalidNullSafe ' )]
380
363
public function testNullSafeEvaluateFails ($ expression , $ foo , $ message )
381
364
{
382
365
$ expressionLanguage = new ExpressionLanguage ();
@@ -386,9 +369,7 @@ public function testNullSafeEvaluateFails($expression, $foo, $message)
386
369
$ expressionLanguage ->evaluate ($ expression , ['foo ' => $ foo ]);
387
370
}
388
371
389
- /**
390
- * @dataProvider provideInvalidNullSafe
391
- */
372
+ #[DataProvider('provideInvalidNullSafe ' )]
392
373
public function testNullSafeCompileFails ($ expression , $ foo )
393
374
{
394
375
$ expressionLanguage = new ExpressionLanguage ();
@@ -417,18 +398,14 @@ public static function provideInvalidNullSafe()
417
398
yield ['foo?.bar["baz"].qux.quux ' , (object ) ['bar ' => ['baz ' => null ]], 'Unable to get property "qux" of non-object "foo?.bar["baz"]". ' ];
418
399
}
419
400
420
- /**
421
- * @dataProvider provideNullCoalescing
422
- */
401
+ #[DataProvider('provideNullCoalescing ' )]
423
402
public function testNullCoalescingEvaluate ($ expression , $ foo )
424
403
{
425
404
$ expressionLanguage = new ExpressionLanguage ();
426
405
$ this ->assertSame ($ expressionLanguage ->evaluate ($ expression , ['foo ' => $ foo ]), 'default ' );
427
406
}
428
407
429
- /**
430
- * @dataProvider provideNullCoalescing
431
- */
408
+ #[DataProvider('provideNullCoalescing ' )]
432
409
public function testNullCoalescingCompile ($ expression , $ foo )
433
410
{
434
411
$ expressionLanguage = new ExpressionLanguage ();
@@ -459,9 +436,7 @@ public function bar()
459
436
yield ['foo[123][456][789] ?? "default" ' , [123 => []]];
460
437
}
461
438
462
- /**
463
- * @dataProvider getRegisterCallbacks
464
- */
439
+ #[DataProvider('getRegisterCallbacks ' )]
465
440
public function testRegisterAfterCompile ($ registerCallback )
466
441
{
467
442
$ this ->expectException (\LogicException::class);
@@ -478,9 +453,7 @@ public static function validCommentProvider()
478
453
yield ["/* multi \nline */ 'foo' " ];
479
454
}
480
455
481
- /**
482
- * @dataProvider validCommentProvider
483
- */
456
+ #[DataProvider('validCommentProvider ' )]
484
457
public function testLintAllowsComments ($ expression )
485
458
{
486
459
$ el = new ExpressionLanguage ();
@@ -496,9 +469,7 @@ public static function invalidCommentProvider()
496
469
yield ['1 /* double closing */ */ ' ];
497
470
}
498
471
499
- /**
500
- * @dataProvider invalidCommentProvider
501
- */
472
+ #[DataProvider('invalidCommentProvider ' )]
502
473
public function testLintThrowsOnInvalidComments ($ expression )
503
474
{
504
475
$ el = new ExpressionLanguage ();
0 commit comments