diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index d31af1aab2e20..42d0d443a1e8e 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -47,6 +47,7 @@ '/s', ]), ], + 'php_unit_attributes' => true, ]) ->setRiskyAllowed(true) ->setFinder( diff --git a/src/Symfony/Bridge/Doctrine/Tests/ArgumentResolver/EntityValueResolverTest.php b/src/Symfony/Bridge/Doctrine/Tests/ArgumentResolver/EntityValueResolverTest.php index 1633f28ee0dfb..39f60320a5e9c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ArgumentResolver/EntityValueResolverTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ArgumentResolver/EntityValueResolverTest.php @@ -16,6 +16,7 @@ use Doctrine\Persistence\Mapping\ClassMetadata; use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectRepository; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\MockObject\MockObject; @@ -109,9 +110,7 @@ public function testResolveWithStripNulls() $this->assertSame([], $resolver->resolve($request, $argument)); } - /** - * @dataProvider idsProvider - */ + #[DataProvider('idsProvider')] public function testResolveWithId(string|int $id) { $manager = $this->createMock(ObjectManager::class); @@ -137,9 +136,7 @@ public function testResolveWithId(string|int $id) $this->assertSame([$object], $resolver->resolve($request, $argument)); } - /** - * @dataProvider idsProvider - */ + #[DataProvider('idsProvider')] public function testResolveWithIdAndTypeAlias(string|int $id) { $manager = $this->getMockBuilder(ObjectManager::class)->getMock(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php index b64a1cc4475c6..7138e1721b516 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php @@ -15,6 +15,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\Persistence\ManagerRegistry; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector; use Symfony\Bridge\Doctrine\Middleware\Debug\DebugDataHolder; @@ -148,9 +149,7 @@ public function testReset() $this->assertEquals([], $c->getQueries()); } - /** - * @dataProvider paramProvider - */ + #[DataProvider('paramProvider')] public function testCollectQueries($param, $types, $expected) { $queries = [ @@ -199,9 +198,7 @@ public function testCollectQueryWithNoParams() $this->assertTrue($collectedQueries['default'][1]['runnable']); } - /** - * @dataProvider paramProvider - */ + #[DataProvider('paramProvider')] public function testSerialization($param, array $types, $expected) { $queries = [ diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php index 75cc439cd9923..91ca76b14972b 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension; @@ -145,9 +146,7 @@ public static function getAutomappingData() ]; } - /** - * @dataProvider getAutomappingData - */ + #[DataProvider('getAutomappingData')] public function testFixManagersAutoMappings(array $originalEm1, array $originalEm2, array $expectedEm1, array $expectedEm2) { $emConfigs = [ @@ -187,9 +186,7 @@ public static function providerBasicDrivers(): array ]; } - /** - * @dataProvider providerBasicDrivers - */ + #[DataProvider('providerBasicDrivers')] public function testLoadBasicCacheDriver(string $class, array $config, array $expectedCalls = []) { $container = $this->createContainer(); @@ -270,9 +267,7 @@ public static function providerBundles(): iterable yield ['NewXmlBundle', 'xml', '/config/doctrine']; } - /** - * @dataProvider providerBundles - */ + #[DataProvider('providerBundles')] public function testBundleAutoMapping(string $bundle, string $expectedType, string $dirSuffix) { $bundleDir = __DIR__.'/../Fixtures/Bundles/'.$bundle; diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php index 017b327b8a6eb..bbbb7459f1b5d 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php @@ -17,6 +17,7 @@ use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader; @@ -111,9 +112,7 @@ public function testFilterNonIntegerValues() $loader->getEntitiesByIds('id', [1, '', 2, 3, 'foo', '9223372036854775808']); } - /** - * @dataProvider provideGuidEntityClasses - */ + #[DataProvider('provideGuidEntityClasses')] public function testFilterEmptyUuids(string $entityClass) { $em = DoctrineTestHelper::createTestEntityManager(); @@ -145,9 +144,7 @@ public function testFilterEmptyUuids(string $entityClass) $loader->getEntitiesByIds('id', ['71c5fd46-3f16-4abb-bad7-90ac1e654a2d', '', 'b98e8e11-2897-44df-ad24-d2627eb7f499']); } - /** - * @dataProvider provideUidEntityClasses - */ + #[DataProvider('provideUidEntityClasses')] public function testFilterUid(string $entityClass) { if (Type::hasType('uuid')) { @@ -188,9 +185,7 @@ public function testFilterUid(string $entityClass) $loader->getEntitiesByIds('id', ['71c5fd46-3f16-4abb-bad7-90ac1e654a2d', '', 'b98e8e11-2897-44df-ad24-d2627eb7f499']); } - /** - * @dataProvider provideUidEntityClasses - */ + #[DataProvider('provideUidEntityClasses')] public function testUidThrowProperException(string $entityClass) { if (Type::hasType('uuid')) { diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php index 930ee9994879e..b55ac9c0f3549 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php @@ -17,6 +17,7 @@ use Doctrine\ORM\Mapping\ManyToOneAssociationMapping; use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ObjectManager; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser; use Symfony\Component\Form\Guess\Guess; @@ -25,9 +26,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase { - /** - * @dataProvider requiredType - */ + #[DataProvider('requiredType')] public function testTypeGuesser(string $type, $expected) { $classMetadata = $this->createMock(ClassMetadata::class); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php index e010600c9165c..600374ee37d1b 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php @@ -14,6 +14,7 @@ use Doctrine\ORM\EntityManager; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Persistence\ManagerRegistry; +use PHPUnit\Framework\Attributes\Group; use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension; use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity; @@ -81,9 +82,8 @@ protected function setUp(): void /** * This test case is realistic in collection forms where each * row contains the same entity field. - * - * @group benchmark */ + #[Group('benchmark')] public function testCollapsedEntityField() { $this->setMaxRunningTime(1); @@ -98,9 +98,7 @@ public function testCollapsedEntityField() } } - /** - * @group benchmark - */ + #[Group('benchmark')] public function testCollapsedEntityFieldWithChoices() { $choices = $this->em->createQuery('SELECT c FROM '.self::ENTITY_CLASS.' c')->getResult(); @@ -117,9 +115,7 @@ public function testCollapsedEntityFieldWithChoices() } } - /** - * @group benchmark - */ + #[Group('benchmark')] public function testCollapsedEntityFieldWithPreferredChoices() { $choices = $this->em->createQuery('SELECT c FROM '.self::ENTITY_CLASS.' c')->getResult(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index aa12fdb7752b0..a61da6dc5db04 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -16,6 +16,7 @@ use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Persistence\ManagerRegistry; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension; use Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser; @@ -119,9 +120,7 @@ public function testInvalidClassOption() ]); } - /** - * @dataProvider choiceTranslationDomainProvider - */ + #[DataProvider('choiceTranslationDomainProvider')] public function testChoiceTranslationDomainIsDisabledByDefault($expanded) { $entity1 = new SingleIntIdEntity(1, 'Foo'); diff --git a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php index 53caa9da42e77..3e94e03565b63 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php @@ -12,6 +12,8 @@ namespace Symfony\Bridge\Doctrine\Tests; use Doctrine\Persistence\ObjectManager; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresPhp; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Tests\Fixtures\DummyManager; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -49,11 +51,8 @@ public function testResetService() $this->assertFalse(isset($foo->bar)); } - /** - * @requires PHP 8.4 - * - * @dataProvider provideResetServiceWithNativeLazyObjectsCases - */ + #[DataProvider('provideResetServiceWithNativeLazyObjectsCases')] + #[RequiresPhp('8.4')] public function testResetServiceWithNativeLazyObjects(string $class) { $container = new $class(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php b/src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php index eb3acbba903a5..81111c11c7871 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php @@ -21,15 +21,15 @@ use Doctrine\DBAL\Statement; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\ORMSetup; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Middleware\Debug\DebugDataHolder; use Symfony\Bridge\Doctrine\Middleware\Debug\Middleware; use Symfony\Bridge\PhpUnit\ClockMock; use Symfony\Component\Stopwatch\Stopwatch; -/** - * @requires extension pdo_sqlite - */ +#[RequiresPhpExtension('pdo_sqlite')] class MiddlewareTest extends TestCase { private DebugDataHolder $debugDataHolder; @@ -93,9 +93,7 @@ public static function provideExecuteMethod(): array ]; } - /** - * @dataProvider provideExecuteMethod - */ + #[DataProvider('provideExecuteMethod')] public function testWithoutBinding(callable $executeMethod) { $this->init(); @@ -110,9 +108,7 @@ public function testWithoutBinding(callable $executeMethod) $this->assertGreaterThan(0, $debug[1]['executionMS']); } - /** - * @dataProvider provideExecuteMethod - */ + #[DataProvider('provideExecuteMethod')] public function testWithValueBound(callable $executeMethod) { $this->init(); @@ -140,9 +136,7 @@ public function testWithValueBound(callable $executeMethod) $this->assertGreaterThan(0, $debug[1]['executionMS']); } - /** - * @dataProvider provideExecuteMethod - */ + #[DataProvider('provideExecuteMethod')] public function testWithParamBound(callable $executeMethod) { $this->init(); @@ -179,9 +173,7 @@ public static function provideEndTransactionMethod(): array ]; } - /** - * @dataProvider provideEndTransactionMethod - */ + #[DataProvider('provideEndTransactionMethod')] public function testTransaction(callable $endTransactionMethod, string $expectedEndTransactionDebug) { $this->init(); @@ -237,9 +229,7 @@ public static function provideExecuteAndEndTransactionMethods(): array ]; } - /** - * @dataProvider provideExecuteAndEndTransactionMethods - */ + #[DataProvider('provideExecuteAndEndTransactionMethods')] public function testGlobalDoctrineDuration(callable $sqlMethod, callable $endTransactionMethod) { $this->init(); @@ -263,9 +253,7 @@ public function testGlobalDoctrineDuration(callable $sqlMethod, callable $endTra $this->assertCount(4, $this->stopwatch->getEvent('doctrine')->getPeriods()); } - /** - * @dataProvider provideExecuteAndEndTransactionMethods - */ + #[DataProvider('provideExecuteAndEndTransactionMethods')] public function testWithoutStopwatch(callable $sqlMethod, callable $endTransactionMethod) { $this->init(false); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Middleware/IdleConnection/DriverTest.php b/src/Symfony/Bridge/Doctrine/Tests/Middleware/IdleConnection/DriverTest.php index 010e1879a8ab4..89c0b0051fd75 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Middleware/IdleConnection/DriverTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Middleware/IdleConnection/DriverTest.php @@ -13,14 +13,13 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\Connection as ConnectionInterface; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Middleware\IdleConnection\Driver; class DriverTest extends TestCase { - /** - * @group time-sensitive - */ + #[Group('time-sensitive')] public function testConnect() { $driverMock = $this->createMock(DriverInterface::class); diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php index e3f576e42705c..12f187827ab8a 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php @@ -294,9 +294,7 @@ public function testExtractEnum() $this->assertNull($this->createExtractor()->getType(DoctrineEnum::class, 'enumCustom')); } - /** - * @dataProvider typeProvider - */ + #[DataProvider('typeProvider')] public function testExtract(string $property, ?Type $type) { $this->assertEquals($type, $this->createExtractor()->getType(DoctrineDummy::class, $property, [])); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderPostgresTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderPostgresTest.php index 230ec78dc23cf..90d5f00f9b02f 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderPostgresTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderPostgresTest.php @@ -15,13 +15,12 @@ use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory; use Doctrine\ORM\ORMSetup; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider; -/** - * @requires extension pdo_pgsql - * - * @group integration - */ +#[Group('integration')] +#[RequiresPhpExtension('pdo_pgsql')] class DoctrineTokenProviderPostgresTest extends DoctrineTokenProviderTest { public static function setUpBeforeClass(): void diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php index 2971f4d662089..1a9b4ae77987c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php @@ -14,14 +14,13 @@ use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory; use Doctrine\ORM\ORMSetup; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider; use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken; use Symfony\Component\Security\Core\Exception\TokenNotFoundException; -/** - * @requires extension pdo_sqlite - */ +#[RequiresPhpExtension('pdo_sqlite')] class DoctrineTokenProviderTest extends TestCase { public function testCreateNewToken() diff --git a/src/Symfony/Bridge/Doctrine/Tests/Types/UlidTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Types/UlidTypeTest.php index b490d94f4263f..e150fe21db523 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Types/UlidTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Types/UlidTypeTest.php @@ -18,6 +18,7 @@ use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Types\UlidType; use Symfony\Component\Uid\AbstractUid; @@ -129,9 +130,7 @@ public function testGetName() $this->assertEquals('ulid', $this->type->getName()); } - /** - * @dataProvider provideSqlDeclarations - */ + #[DataProvider('provideSqlDeclarations')] public function testGetGuidTypeDeclarationSQL(AbstractPlatform $platform, string $expectedDeclaration) { $this->assertEquals($expectedDeclaration, $this->type->getSqlDeclaration(['length' => 36], $platform)); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Types/UuidTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Types/UuidTypeTest.php index f26e43ffe66b3..a5a702c70c78a 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Types/UuidTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Types/UuidTypeTest.php @@ -18,6 +18,7 @@ use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\AbstractUid; @@ -140,9 +141,7 @@ public function testGetName() $this->assertEquals('uuid', $this->type->getName()); } - /** - * @dataProvider provideSqlDeclarations - */ + #[DataProvider('provideSqlDeclarations')] public function testGetGuidTypeDeclarationSQL(AbstractPlatform $platform, string $expectedDeclaration) { $this->assertEquals($expectedDeclaration, $this->type->getSqlDeclaration(['length' => 36], $platform)); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index c6d4024f21988..b532a3471ec73 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -17,6 +17,7 @@ use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ObjectManager; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\MockObject\MockObject; @@ -267,10 +268,8 @@ public function testValidateUniquenessWithNull() $this->assertNoViolation(); } - /** - * @dataProvider provideConstraintsWithIgnoreNullDisabled - * @dataProvider provideConstraintsWithIgnoreNullEnabledOnFirstField - */ + #[DataProvider('provideConstraintsWithIgnoreNullDisabled')] + #[DataProvider('provideConstraintsWithIgnoreNullEnabledOnFirstField')] public function testValidateUniquenessWithIgnoreNullDisableOnSecondField(UniqueEntity $constraint) { $entity1 = new DoubleNameEntity(1, 'Foo', null); @@ -303,9 +302,7 @@ public static function provideConstraintsWithIgnoreNullDisabled(): iterable yield 'Named arguments' => [new UniqueEntity(message: 'myMessage', fields: ['name', 'name2'], em: 'foo', ignoreNull: false)]; } - /** - * @dataProvider provideConstraintsWithIgnoreNullEnabled - */ + #[DataProvider('provideConstraintsWithIgnoreNullEnabled')] public function testAllConfiguredFieldsAreCheckedOfBeingMappedByDoctrineWithIgnoreNullEnabled(UniqueEntity $constraint) { $entity1 = new SingleIntIdEntity(1, null); @@ -314,10 +311,8 @@ public function testAllConfiguredFieldsAreCheckedOfBeingMappedByDoctrineWithIgno $this->validator->validate($entity1, $constraint); } - /** - * @dataProvider provideConstraintsWithIgnoreNullEnabled - * @dataProvider provideConstraintsWithIgnoreNullEnabledOnFirstField - */ + #[DataProvider('provideConstraintsWithIgnoreNullEnabled')] + #[DataProvider('provideConstraintsWithIgnoreNullEnabledOnFirstField')] public function testNoValidationIfFirstFieldIsNullAndNullValuesAreIgnored(UniqueEntity $constraint) { $entity1 = new DoubleNullableNameEntity(1, null, 'Foo'); @@ -414,9 +409,7 @@ public function testValidateUniquenessWithUnrewoundArray() $this->assertNoViolation(); } - /** - * @dataProvider resultTypesProvider - */ + #[DataProvider('resultTypesProvider')] public function testValidateResultTypes($entity1, $result) { $constraint = new UniqueEntity( @@ -817,9 +810,7 @@ public function testValidateUniquenessCause() ->assertRaised(); } - /** - * @dataProvider resultWithEmptyIterator - */ + #[DataProvider('resultWithEmptyIterator')] public function testValidateUniquenessWithEmptyIterator($entity, $result) { $constraint = new UniqueEntity( diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php index 8b3494961d80b..9c0004b5723fb 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Doctrine\Tests\Validator; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper; use Symfony\Bridge\Doctrine\Tests\Fixtures\BaseUser; @@ -175,9 +176,7 @@ public function testFieldMappingsConfiguration() $this->assertCount(0, $constraints); } - /** - * @dataProvider regexpProvider - */ + #[DataProvider('regexpProvider')] public function testClassValidator(bool $expected, ?string $classValidatorRegexp = null) { $doctrineLoader = new DoctrineLoader(DoctrineTestHelper::createTestEntityManager(), $classValidatorRegexp, false); diff --git a/src/Symfony/Bridge/Monolog/Tests/Formatter/ConsoleFormatterTest.php b/src/Symfony/Bridge/Monolog/Tests/Formatter/ConsoleFormatterTest.php index 2a952abc350e2..6f72498525303 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Formatter/ConsoleFormatterTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Formatter/ConsoleFormatterTest.php @@ -13,15 +13,14 @@ use Monolog\Logger; use Monolog\LogRecord; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter; use Symfony\Bridge\Monolog\Tests\RecordFactory; class ConsoleFormatterTest extends TestCase { - /** - * @dataProvider providerFormatTests - */ + #[DataProvider('providerFormatTests')] public function testFormat(array|LogRecord $record, $expectedMessage) { $formatter = new ConsoleFormatter(); diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php index 626c94ce0ccf8..a4c9420a9d434 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php @@ -13,6 +13,7 @@ use Monolog\Level; use Monolog\Logger; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter; use Symfony\Bridge\Monolog\Handler\ConsoleHandler; @@ -46,9 +47,7 @@ public function testIsHandling() $this->assertFalse($handler->isHandling(RecordFactory::create()), '->isHandling returns false when no output is set'); } - /** - * @dataProvider provideVerbosityMappingTests - */ + #[DataProvider('provideVerbosityMappingTests')] public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = []) { $output = $this->createMock(OutputInterface::class); diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php index 5c96b392d4521..7d84d4f25cd60 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php @@ -13,6 +13,7 @@ use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; use Monolog\Level; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Monolog\Handler\FingersCrossed\HttpCodeActivationStrategy; use Symfony\Bridge\Monolog\Tests\RecordFactory; @@ -34,9 +35,7 @@ public function testExclusionsWithoutUrls() new HttpCodeActivationStrategy(new RequestStack(), [['code' => 404]], new ErrorLevelActivationStrategy(Level::Warning)); } - /** - * @dataProvider isActivatedProvider - */ + #[DataProvider('isActivatedProvider')] public function testIsActivated($url, $record, $expected) { $requestStack = new RequestStack(); diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php index 48a1347421c05..2d1779bd4bfd7 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php @@ -14,6 +14,7 @@ use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; use Monolog\Level; use Monolog\LogRecord; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Monolog\Handler\FingersCrossed\NotFoundActivationStrategy; use Symfony\Bridge\Monolog\Tests\RecordFactory; @@ -23,9 +24,7 @@ class NotFoundActivationStrategyTest extends TestCase { - /** - * @dataProvider isActivatedProvider - */ + #[DataProvider('isActivatedProvider')] public function testIsActivated(string $url, array|LogRecord $record, bool $expected) { $requestStack = new RequestStack(); diff --git a/src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php b/src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php index 84241081f7ba0..95c354e184ecb 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ClockMock; @@ -19,6 +20,7 @@ * * @covers \Symfony\Bridge\PhpUnit\ClockMock */ +#[CoversClass(ClockMock::class)] class ClockMockTest extends TestCase { public static function setUpBeforeClass(): void diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php index 741c1a5ac3f04..3faadf33d8f70 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration; @@ -194,6 +195,7 @@ public static function provideItCanBeDisabled(): array /** * @dataProvider provideItCanBeDisabled */ + #[DataProvider('provideItCanBeDisabled')] public function testItCanBeDisabled(string $encodedString, bool $expectedEnabled) { $configuration = Configuration::fromUrlEncodedString($encodedString); @@ -240,6 +242,7 @@ public function testOutputIsNotVerboseInWeakMode() /** * @dataProvider provideDataForToleratesForGroup */ + #[DataProvider('provideDataForToleratesForGroup')] public function testToleratesForIndividualGroups(string $deprecationsHelper, array $deprecationsPerType, array $expected) { $configuration = Configuration::fromUrlEncodedString($deprecationsHelper); diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php index 1519b83a838b7..337fbd1fb8992 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation; @@ -88,6 +89,7 @@ public function testItRulesOutFilesOutsideVendorsAsIndirect() /** * @dataProvider mutedProvider */ + #[DataProvider('mutedProvider')] public function testItMutesOnlySpecificErrorMessagesWhenTheCallingCodeIsInPhpunit($muted, $callingClass, $message) { $trace = $this->debugBacktrace(); @@ -170,6 +172,7 @@ public static function providerGetTypeDetectsSelf(): array /** * @dataProvider providerGetTypeDetectsSelf */ + #[DataProvider('providerGetTypeDetectsSelf')] public function testGetTypeDetectsSelf(string $expectedType, string $message, string $traceClass, string $file) { $trace = [ @@ -233,6 +236,7 @@ public static function providerGetTypeUsesRightTrace(): array /** * @dataProvider providerGetTypeUsesRightTrace */ + #[DataProvider('providerGetTypeUsesRightTrace')] public function testGetTypeUsesRightTrace(string $expectedType, string $message, array $trace) { $deprecation = new Deprecation( diff --git a/src/Symfony/Bridge/PhpUnit/Tests/ExpectDeprecationTraitTest.php b/src/Symfony/Bridge/PhpUnit/Tests/ExpectDeprecationTraitTest.php index 142d3f854cb27..0a4854dd3d453 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/ExpectDeprecationTraitTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/ExpectDeprecationTraitTest.php @@ -11,7 +11,9 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpunit; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; @@ -25,6 +27,7 @@ final class ExpectDeprecationTraitTest extends TestCase * * @group legacy */ + #[Group('legacy')] public function testOne() { $this->expectDeprecation('foo'); @@ -38,6 +41,8 @@ public function testOne() * * @runInSeparateProcess */ + #[Group('legacy')] + #[RunInSeparateProcess] public function testOneInIsolation() { $this->expectDeprecation('foo'); @@ -49,6 +54,7 @@ public function testOneInIsolation() * * @group legacy */ + #[Group('legacy')] public function testMany() { $this->expectDeprecation('foo'); @@ -64,6 +70,7 @@ public function testMany() * * @expectedDeprecation foo */ + #[Group('legacy')] public function testOneWithAnnotation() { $this->expectDeprecation('bar'); @@ -79,6 +86,7 @@ public function testOneWithAnnotation() * @expectedDeprecation foo * @expectedDeprecation bar */ + #[Group('legacy')] public function testManyWithAnnotation() { $this->expectDeprecation('ccc'); diff --git a/src/Symfony/Bridge/PhpUnit/Tests/ExpectedDeprecationAnnotationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/ExpectedDeprecationAnnotationTest.php index 6e7ba0b5f52ab..a3112cf76f1f5 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/ExpectedDeprecationAnnotationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/ExpectedDeprecationAnnotationTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; @@ -24,6 +25,7 @@ final class ExpectedDeprecationAnnotationTest extends TestCase * * @expectedDeprecation foo */ + #[Group('legacy')] public function testOne() { @trigger_error('foo', \E_USER_DEPRECATED); @@ -37,6 +39,7 @@ public function testOne() * @expectedDeprecation foo * @expectedDeprecation bar */ + #[Group('legacy')] public function testMany() { @trigger_error('foo', \E_USER_DEPRECATED); diff --git a/src/Symfony/Bridge/PhpUnit/Tests/FailTests/NoAssertionsTestRisky.php b/src/Symfony/Bridge/PhpUnit/Tests/FailTests/NoAssertionsTestRisky.php index 601506a55fa1b..559b86b832d32 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/FailTests/NoAssertionsTestRisky.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/FailTests/NoAssertionsTestRisky.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests\FailTests; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; @@ -29,6 +30,7 @@ final class NoAssertionsTestRisky extends TestCase * * @group legacy */ + #[Group('legacy')] public function testOne() { $this->expectNotToPerformAssertions(); diff --git a/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversDefaultClassTest.php b/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversDefaultClassTest.php index d764638d04958..503d675b42844 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversDefaultClassTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversDefaultClassTest.php @@ -9,11 +9,13 @@ * file that was distributed with this source code. */ +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \DateTime */ +#[CoversClass(DateTime::class)] class CoversDefaultClassTest extends TestCase { public function test() diff --git a/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversNothingTest.php b/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversNothingTest.php index e60ea97e57bbd..8e3cb0a7f96a7 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversNothingTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversNothingTest.php @@ -9,11 +9,13 @@ * file that was distributed with this source code. */ +use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\TestCase; /** * @coversNothing */ +#[CoversNothing] class CoversNothingTest extends TestCase { public function test() diff --git a/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversTest.php b/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversTest.php index f6d3406046d86..67ac74d7e00c7 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/CoversTest.php @@ -9,13 +9,15 @@ * file that was distributed with this source code. */ +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @covers \DateTime + */ +#[CoversClass(DateTime::class)] class CoversTest extends TestCase { - /** - * @covers \DateTime - */ public function test() { $this->assertTrue(true); diff --git a/src/Symfony/Bridge/PhpUnit/Tests/Metadata/AttributeReaderTest.php b/src/Symfony/Bridge/PhpUnit/Tests/Metadata/AttributeReaderTest.php index d34208dee3a2a..eb3a7765642b1 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/Metadata/AttributeReaderTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/Metadata/AttributeReaderTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests\Metadata; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\Attribute\DnsSensitive; use Symfony\Bridge\PhpUnit\Attribute\TimeSensitive; @@ -22,6 +23,7 @@ class AttributeReaderTest extends TestCase /** * @dataProvider provideReadCases */ + #[DataProvider('provideReadCases')] public function testAttributesAreRead(string $method, string $attributeClass, array $expected) { $reader = new AttributeReader(); diff --git a/src/Symfony/Bridge/PhpUnit/Tests/OnlyExpectingDeprecationSkippedTest.php b/src/Symfony/Bridge/PhpUnit/Tests/OnlyExpectingDeprecationSkippedTest.php index 593e0b4e14342..aede756a586a3 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/OnlyExpectingDeprecationSkippedTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/OnlyExpectingDeprecationSkippedTest.php @@ -11,6 +11,8 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; /** @@ -18,6 +20,7 @@ * * @requires extension ext-dummy */ +#[RequiresPhpExtension('ext-dummy')] final class OnlyExpectingDeprecationSkippedTest extends TestCase { /** @@ -27,6 +30,7 @@ final class OnlyExpectingDeprecationSkippedTest extends TestCase * * @expectedDeprecation unreachable */ + #[Group('legacy')] public function testExpectingOnlyDeprecations() { $this->fail('should never be ran.'); diff --git a/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php index b517fe523ebf4..9e043d0eb1887 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; @@ -22,6 +23,7 @@ * @runTestsInSeparateProcesses */ #[RequiresPhpunit('<10')] +#[Group('legacy')] class ProcessIsolationTest extends TestCase { /** diff --git a/src/Symfony/Bridge/PsrHttpMessage/Tests/Factory/PsrHttpFactoryTest.php b/src/Symfony/Bridge/PsrHttpMessage/Tests/Factory/PsrHttpFactoryTest.php index f5b09c82beb68..bdb037788db63 100644 --- a/src/Symfony/Bridge/PsrHttpMessage/Tests/Factory/PsrHttpFactoryTest.php +++ b/src/Symfony/Bridge/PsrHttpMessage/Tests/Factory/PsrHttpFactoryTest.php @@ -12,6 +12,7 @@ namespace Symfony\Bridge\PsrHttpMessage\Tests\Factory; use Nyholm\Psr7\Factory\Psr17Factory; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory; use Symfony\Component\HttpFoundation\BinaryFileResponse; @@ -35,9 +36,7 @@ protected function setUp(): void $this->tmpDir = sys_get_temp_dir(); } - /** - * @dataProvider provideFactories - */ + #[DataProvider('provideFactories')] public function testCreateRequest(PsrHttpFactory $factory) { $stdClass = new \stdClass(); @@ -137,9 +136,7 @@ private function createUploadedFile(string $content, string $originalName, strin return new UploadedFile($path, $originalName, $mimeType, $error, true); } - /** - * @dataProvider provideFactories - */ + #[DataProvider('provideFactories')] public function testCreateResponse(PsrHttpFactory $factory) { $response = new Response( diff --git a/src/Symfony/Bridge/PsrHttpMessage/Tests/Functional/CovertTest.php b/src/Symfony/Bridge/PsrHttpMessage/Tests/Functional/CovertTest.php index e2280aad2a906..e5489745b1625 100644 --- a/src/Symfony/Bridge/PsrHttpMessage/Tests/Functional/CovertTest.php +++ b/src/Symfony/Bridge/PsrHttpMessage/Tests/Functional/CovertTest.php @@ -15,6 +15,7 @@ use Nyholm\Psr7\Response as Psr7Response; use Nyholm\Psr7\ServerRequest as Psr7Request; use Nyholm\Psr7\Stream as Psr7Stream; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -41,9 +42,7 @@ protected function setUp(): void } } - /** - * @dataProvider requestProvider - */ + #[DataProvider('requestProvider')] public function testConvertRequestMultipleTimes(ServerRequestInterface|Request $request, HttpMessageFactoryInterface|HttpFoundationFactoryInterface $firstFactory, HttpMessageFactoryInterface|HttpFoundationFactoryInterface $secondFactory) { $temporaryRequest = $firstFactory->createRequest($request); @@ -151,9 +150,7 @@ public static function requestProvider(): array }, $psr7Requests)); } - /** - * @dataProvider responseProvider - */ + #[DataProvider('responseProvider')] public function testConvertResponseMultipleTimes(ResponseInterface|Response $response, HttpMessageFactoryInterface|HttpFoundationFactoryInterface $firstFactory, HttpMessageFactoryInterface|HttpFoundationFactoryInterface $secondFactory) { $temporaryResponse = $firstFactory->createResponse($response); diff --git a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php index 0367f7704b684..697acffa106ca 100644 --- a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php +++ b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php @@ -11,6 +11,8 @@ namespace Symfony\Bridge\Twig\Tests; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\AppVariable; use Symfony\Component\HttpFoundation\Request; @@ -31,9 +33,7 @@ protected function setUp(): void $this->appVariable = new AppVariable(); } - /** - * @dataProvider debugDataProvider - */ + #[DataProvider('debugDataProvider')] public function testDebug($debugFlag) { $this->appVariable->setDebug($debugFlag); @@ -56,9 +56,7 @@ public function testEnvironment() $this->assertEquals('dev', $this->appVariable->getEnvironment()); } - /** - * @runInSeparateProcess - */ + #[RunInSeparateProcess] public function testGetSession() { $request = $this->createMock(Request::class); @@ -192,18 +190,14 @@ public function testGetFlashesWithNoRequest() $this->assertEquals([], $this->appVariable->getFlashes()); } - /** - * @runInSeparateProcess - */ + #[RunInSeparateProcess] public function testGetFlashesWithNoSessionStarted() { $flashMessages = $this->setFlashMessages(false); $this->assertEquals($flashMessages, $this->appVariable->getFlashes()); } - /** - * @runInSeparateProcess - */ + #[RunInSeparateProcess] public function testGetFlashes() { $flashMessages = $this->setFlashMessages(); diff --git a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php index 2107ca2efc498..d8420e23e6a25 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Command\DebugCommand; use Symfony\Component\Console\Application; @@ -72,9 +73,7 @@ public function testMalformedTemplateName() $this->createCommandTester()->execute(['name' => '@foo']); } - /** - * @dataProvider getDebugTemplateNameTestData - */ + #[DataProvider('getDebugTemplateNameTestData')] public function testDebugTemplateName(array $input, string $output, array $paths) { $tester = $this->createCommandTester($paths); @@ -294,9 +293,7 @@ public function testWithFilter() $this->assertNotSame($display1, $display2); } - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions) { $projectDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'; diff --git a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php index 931ad4ec41306..165119978872f 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\TestCase; @@ -113,9 +114,7 @@ public function testLintFileWithMultipleReportedDeprecation() $this->assertStringContainsString('Filter "deprecated_filter" is deprecated', trim($tester->getDisplay())); } - /** - * @group tty - */ + #[Group('tty')] public function testLintDefaultPaths() { $tester = $this->createCommandTester(); @@ -152,9 +151,7 @@ public function testLintAutodetectsGithubActionEnvironment() } } - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions) { $tester = new CommandCompletionTester($this->createCommand()); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractDivLayoutTestCase.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractDivLayoutTestCase.php index 28e8997a12e9f..171d13effbd65 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractDivLayoutTestCase.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractDivLayoutTestCase.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Form\FormError; use Symfony\Component\Security\Csrf\CsrfToken; @@ -601,9 +602,7 @@ public function testLabelIsNotRenderedWhenSetToFalse() ); } - /** - * @dataProvider themeBlockInheritanceProvider - */ + #[DataProvider('themeBlockInheritanceProvider')] public function testThemeBlockInheritance($theme) { $view = $this->factory @@ -626,9 +625,7 @@ public static function themeBlockInheritanceProvider(): array ]; } - /** - * @dataProvider themeInheritanceProvider - */ + #[DataProvider('themeInheritanceProvider')] public function testThemeInheritance($parentTheme, $childTheme) { $child = $this->factory->createNamedBuilder('child', 'Symfony\Component\Form\Extension\Core\Type\FormType') diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractLayoutTestCase.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractLayoutTestCase.php index 2f7410d1f7591..75d6050d116f9 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractLayoutTestCase.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractLayoutTestCase.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use Symfony\Bridge\Twig\Test\FormLayoutTestCase; use Symfony\Component\Form\Extension\Core\Type\PercentType; @@ -2711,9 +2712,7 @@ public function testButtonWithTranslationParameters() ); } - /** - * @dataProvider submitFormNoValidateProvider - */ + #[DataProvider('submitFormNoValidateProvider')] public function testSubmitFormNoValidate(bool $validate) { $form = $this->factory->create(SubmitType::class, null, [ diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php index 01817ce597c5d..b182b59f67aa6 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\DumpExtension; use Symfony\Component\VarDumper\Cloner\VarCloner; @@ -22,9 +23,7 @@ class DumpExtensionTest extends TestCase { - /** - * @dataProvider getDumpTags - */ + #[DataProvider('getDumpTags')] public function testDumpTag($template, $debug, $expectedOutput, $expectedDumped) { $extension = new DumpExtension(new VarCloner()); @@ -62,9 +61,7 @@ public static function getDumpTags() ]; } - /** - * @dataProvider getDumpArgs - */ + #[DataProvider('getDumpArgs')] public function testDump($context, $args, $expectedOutput, $debug = true) { $extension = new DumpExtension(new VarCloner()); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/EmojiExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/EmojiExtensionTest.php index 492929a341e7d..61b2178b89a65 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/EmojiExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/EmojiExtensionTest.php @@ -11,19 +11,17 @@ namespace Symfony\Bridge\Twig\Tests\Extension; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\EmojiExtension; -/** - * @requires extension intl - */ +#[RequiresPhpExtension('intl')] class EmojiExtensionTest extends TestCase { - /** - * @testWith ["🅰️", ":a:"] - * ["🅰️", ":a:", "slack"] - * ["🅰", ":a:", "github"] - */ + #[TestWith(['🅰️', ':a:'])] + #[TestWith(['🅰️', ':a:', 'slack'])] + #[TestWith(['🅰', ':a:', 'github'])] public function testEmojify(string $expected, string $string, ?string $catalog = null) { $extension = new EmojiExtension(); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index d0e90b1f2a6f7..066aed57ee526 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Form\TwigRendererEngine; @@ -84,9 +85,7 @@ public static function isSelectedChoiceProvider(): array ]; } - /** - * @dataProvider isSelectedChoiceProvider - */ + #[DataProvider('isSelectedChoiceProvider')] public function testIsChoiceSelected($expected, $choice, $value) { $choice = new ChoiceView($choice, $choice, $choice.' label'); @@ -126,9 +125,7 @@ public static function isRootFormProvider(): array ]; } - /** - * @dataProvider isRootFormProvider - */ + #[DataProvider('isRootFormProvider')] public function testIsRootForm($expected, FormView $formView) { $this->assertSame($expected, \Symfony\Bridge\Twig\Extension\twig_is_root_form($formView)); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php index b92c3f831cb7d..0852bbf96f4c2 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\HttpFoundationExtension; use Symfony\Component\HttpFoundation\Request; @@ -20,9 +21,7 @@ class HttpFoundationExtensionTest extends TestCase { - /** - * @dataProvider getGenerateAbsoluteUrlData - */ + #[DataProvider('getGenerateAbsoluteUrlData')] public function testGenerateAbsoluteUrl($expected, $path, $pathinfo) { $stack = new RequestStack(); @@ -55,9 +54,7 @@ public static function getGenerateAbsoluteUrlData() ]; } - /** - * @dataProvider getGenerateAbsoluteUrlRequestContextData - */ + #[DataProvider('getGenerateAbsoluteUrlRequestContextData')] public function testGenerateAbsoluteUrlWithRequestContext($path, $baseUrl, $host, $scheme, $httpPort, $httpsPort, $expected) { $requestContext = new RequestContext($baseUrl, 'GET', $host, $scheme, $httpPort, $httpsPort, $path); @@ -66,9 +63,7 @@ public function testGenerateAbsoluteUrlWithRequestContext($path, $baseUrl, $host $this->assertEquals($expected, $extension->generateAbsoluteUrl($path)); } - /** - * @dataProvider getGenerateAbsoluteUrlRequestContextData - */ + #[DataProvider('getGenerateAbsoluteUrlRequestContextData')] public function testGenerateAbsoluteUrlWithoutRequestAndRequestContext($path) { $extension = new HttpFoundationExtension(new UrlHelper(new RequestStack())); @@ -105,9 +100,7 @@ public function testGenerateAbsoluteUrlWithScriptFileName() ); } - /** - * @dataProvider getGenerateRelativePathData - */ + #[DataProvider('getGenerateRelativePathData')] public function testGenerateRelativePath($expected, $path, $pathinfo) { $stack = new RequestStack(); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php index 742a74f325b91..def7085ce71fe 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\RoutingExtension; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; @@ -21,9 +22,7 @@ class RoutingExtensionTest extends TestCase { - /** - * @dataProvider getEscapingTemplates - */ + #[DataProvider('getEscapingTemplates')] public function testEscaping($template, $mustBeEscaped) { $twig = new Environment($this->createMock(LoaderInterface::class), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/SecurityExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/SecurityExtensionTest.php index e0ca4dcbb6901..08959d98592e1 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/SecurityExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/SecurityExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ClassExistsMock; use Symfony\Bridge\Twig\Extension\SecurityExtension; @@ -32,9 +33,7 @@ protected function tearDown(): void ClassExistsMock::withMockedClasses([FieldVote::class => true]); } - /** - * @dataProvider provideObjectFieldAclCases - */ + #[DataProvider('provideObjectFieldAclCases')] public function testIsGrantedCreatesFieldVoteObjectWhenFieldNotNull($object, $field, $expectedSubject) { $securityChecker = $this->createMock(AuthorizationCheckerInterface::class); @@ -65,9 +64,7 @@ public function testIsGrantedThrowsWhenFieldNotNullAndFieldVoteClassDoesNotExist $securityExtension->isGranted('ROLE', 'object', 'bar'); } - /** - * @dataProvider provideObjectFieldAclCases - */ + #[DataProvider('provideObjectFieldAclCases')] public function testIsGrantedForUserCreatesFieldVoteObjectWhenFieldNotNull($object, $field, $expectedSubject) { if (!interface_exists(UserAuthorizationCheckerInterface::class)) { diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/SerializerExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/SerializerExtensionTest.php index 610030cec5a9f..b6e1a030dc4c0 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/SerializerExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/SerializerExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\SerializerExtension; use Symfony\Bridge\Twig\Extension\SerializerRuntime; @@ -30,9 +31,7 @@ */ class SerializerExtensionTest extends TestCase { - /** - * @dataProvider serializerDataProvider - */ + #[DataProvider('serializerDataProvider')] public function testSerializeFilter(string $template, string $expectedResult) { $twig = $this->getTwig($template); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php index d7ff03d72ff98..053dc88391584 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\StopwatchExtension; use Symfony\Component\Stopwatch\Stopwatch; @@ -27,9 +28,7 @@ public function testFailIfStoppingWrongEvent() $this->testTiming('{% stopwatch "foo" %}{% endstopwatch "bar" %}', []); } - /** - * @dataProvider getTimingTemplates - */ + #[DataProvider('getTimingTemplates')] public function testTiming($template, $events) { $twig = new Environment(new ArrayLoader(['template' => $template]), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php index f6dd5f623baee..8db52fe7154e5 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Component\Translation\Loader\ArrayLoader; @@ -29,9 +30,7 @@ public function testEscaping() $this->assertEquals('Percent: 12% (approx.)', $output); } - /** - * @dataProvider getTransTests - */ + #[DataProvider('getTransTests')] public function testTrans($template, $expected, array $variables = []) { if ($expected != $this->getTemplate($template)->render($variables)) { diff --git a/src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php b/src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php index cce8ee9a68839..df3071c8d7454 100644 --- a/src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Mime; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Mime\BodyRenderer; use Symfony\Bridge\Twig\Mime\TemplatedEmail; @@ -137,9 +138,7 @@ public function testRenderedOnceUnserializableContext() $this->assertEquals('Text', $email->getTextBody()); } - /** - * @requires extension intl - */ + #[RequiresPhpExtension('intl')] public function testRenderWithLocale() { $localeSwitcher = new LocaleSwitcher('en', []); diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php index 40063c6b7817f..3d3fd6ec25f57 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\NodeVisitor; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\NodeVisitor\TranslationDefaultDomainNodeVisitor; use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor; @@ -24,7 +25,7 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase private static string $message = 'message'; private static string $domain = 'domain'; - /** @dataProvider getDefaultDomainAssignmentTestData */ + #[DataProvider('getDefaultDomainAssignmentTestData')] public function testDefaultDomainAssignment(Node $node) { $env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); @@ -50,7 +51,7 @@ public function testDefaultDomainAssignment(Node $node) $this->assertEquals([[self::$message, self::$domain]], $visitor->getMessages()); } - /** @dataProvider getDefaultDomainAssignmentTestData */ + #[DataProvider('getDefaultDomainAssignmentTestData')] public function testNewModuleWithoutDefaultDomainTag(Node $node) { $env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php index fc48beb6caba1..49a00a539bd0a 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\NodeVisitor; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor; use Twig\Environment; @@ -25,7 +26,7 @@ class TranslationNodeVisitorTest extends TestCase { - /** @dataProvider getMessagesExtractionTestData */ + #[DataProvider('getMessagesExtractionTestData')] public function testMessagesExtraction(Node $node, array $expectedMessages) { $env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); diff --git a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php index 0c4bcdf62f89b..f4d79ffbab5b8 100644 --- a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php +++ b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\TokenParser; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Node\FormThemeNode; use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser; @@ -24,9 +25,7 @@ class FormThemeTokenParserTest extends TestCase { - /** - * @dataProvider getTestsForFormTheme - */ + #[DataProvider('getTestsForFormTheme')] public function testCompile($source, $expected) { $env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php index f9ae8c348e0fb..d649df4ef955e 100644 --- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Translation; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Translation\TwigExtractor; @@ -24,9 +25,7 @@ class TwigExtractorTest extends TestCase { public const CUSTOM_DOMAIN = 'domain'; - /** - * @dataProvider getExtractData - */ + #[DataProvider('getExtractData')] public function testExtract($template, $messages) { $loader = $this->createMock(LoaderInterface::class); @@ -94,9 +93,7 @@ public static function getExtractData() ]; } - /** - * @dataProvider resourcesWithSyntaxErrorsProvider - */ + #[DataProvider('resourcesWithSyntaxErrorsProvider')] public function testExtractSyntaxError($resources, array $messages) { $twig = new Environment($this->createMock(LoaderInterface::class)); @@ -117,9 +114,7 @@ public static function resourcesWithSyntaxErrorsProvider(): array ]; } - /** - * @dataProvider resourceProvider - */ + #[DataProvider('resourceProvider')] public function testExtractWithFiles($resource) { $loader = new ArrayLoader([]); diff --git a/src/Symfony/Bridge/Twig/Tests/Validator/Constraints/TwigValidatorTest.php b/src/Symfony/Bridge/Twig/Tests/Validator/Constraints/TwigValidatorTest.php index 1a58a9c09ea7b..f41e06dc35e58 100644 --- a/src/Symfony/Bridge/Twig/Tests/Validator/Constraints/TwigValidatorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Validator/Constraints/TwigValidatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Validator\Constraints; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use Symfony\Bridge\Twig\Validator\Constraints\Twig; @@ -41,9 +42,7 @@ protected function createValidator(): TwigValidator return new TwigValidator($environment); } - /** - * @dataProvider getValidValues - */ + #[DataProvider('getValidValues')] public function testTwigIsValid($value) { $this->validator->validate($value, new Twig()); @@ -51,9 +50,7 @@ public function testTwigIsValid($value) $this->assertNoViolation(); } - /** - * @dataProvider getInvalidValues - */ + #[DataProvider('getInvalidValues')] public function testInvalidValues($value, $message, $line) { $constraint = new Twig('myMessageTest'); diff --git a/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php b/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php index 51090815b9cc1..bc90fec759933 100644 --- a/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php +++ b/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\DebugBundle\Tests\DependencyInjection; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\DebugBundle\DebugBundle; use Symfony\Bundle\DebugBundle\DependencyInjection\DebugExtension; @@ -80,9 +81,7 @@ public static function provideServicesUsingDumpDestinationCreation(): array ]; } - /** - * @dataProvider provideServicesUsingDumpDestinationCreation - */ + #[DataProvider('provideServicesUsingDumpDestinationCreation')] public function testServicesUsingDumpDestinationCreation(?string $dumpDestination, string $expectedHost, ?string $expectedOutput) { $container = $this->createContainer(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php index f17aad0e3dc60..5c19d2a3f530a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\CacheWarmer\SerializerCacheWarmer; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\Cache\Adapter\NullAdapter; @@ -38,9 +39,7 @@ private function getArrayPool(string $file): PhpArrayAdapter return $this->arrayPool = new PhpArrayAdapter($file, new NullAdapter()); } - /** - * @dataProvider loaderProvider - */ + #[DataProvider('loaderProvider')] public function testWarmUp(array $loaders) { $file = sys_get_temp_dir().'/cache-serializer.php'; @@ -57,9 +56,7 @@ public function testWarmUp(array $loaders) $this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit()); } - /** - * @dataProvider loaderProvider - */ + #[DataProvider('loaderProvider')] public function testWarmUpAbsoluteFilePath(array $loaders) { $file = sys_get_temp_dir().'/0/cache-serializer.php'; @@ -79,9 +76,7 @@ public function testWarmUpAbsoluteFilePath(array $loaders) $this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit()); } - /** - * @dataProvider loaderProvider - */ + #[DataProvider('loaderProvider')] public function testWarmUpWithoutBuildDir(array $loaders) { $file = sys_get_temp_dir().'/cache-serializer.php'; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolClearCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolClearCommandTest.php index c98d7ed920274..dcf7881346cbd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolClearCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolClearCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use Psr\Cache\CacheItemPoolInterface; use Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand; @@ -30,9 +31,7 @@ protected function setUp(): void $this->cachePool = $this->createMock(CacheItemPoolInterface::class); } - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions) { $application = new Application($this->getKernel()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php index b4c11d4db3edd..afd3ecdd79f79 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use Psr\Cache\CacheItemPoolInterface; use Symfony\Bundle\FrameworkBundle\Command\CachePoolDeleteCommand; @@ -84,9 +85,7 @@ public function testCommandDeleteFailed() $tester->execute(['pool' => 'foo', 'key' => 'bar']); } - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions) { $application = new Application($this->getKernel()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php index 359196e11dd28..7dc1e0dc64bfb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Command\EventDispatcherDebugCommand; use Symfony\Component\Console\Tester\CommandCompletionTester; @@ -20,9 +21,7 @@ class EventDispatcherDebugCommandTest extends TestCase { - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions) { $tester = $this->createCommandCompletionTester(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsListCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsListCommandTest.php index 12d3ab2e8ac28..de09d8941b240 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsListCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsListCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; +use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Command\SecretsListCommand; use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault; @@ -19,9 +20,7 @@ class SecretsListCommandTest extends TestCase { - /** - * @backupGlobals enabled - */ + #[BackupGlobals(true)] public function testExecute() { $vault = $this->createMock(AbstractVault::class); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRemoveCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRemoveCommandTest.php index 2c12b6128d9f5..d09fa3c019cdc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRemoveCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRemoveCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Command\SecretsRemoveCommand; use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault; @@ -18,9 +19,7 @@ class SecretsRemoveCommandTest extends TestCase { - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(bool $withLocalVault, array $input, array $expectedSuggestions) { $vault = $this->createMock(AbstractVault::class); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRevealCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRevealCommandTest.php index d77d303d5c88b..37065d1c0a973 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRevealCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRevealCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; +use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Command\SecretsRevealCommand; use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault; @@ -59,9 +60,7 @@ public function testFailedDecrypt() $this->assertStringContainsString('The secret "secretKey" could not be decrypted.', trim($tester->getDisplay(true))); } - /** - * @backupGlobals enabled - */ + #[BackupGlobals(true)] public function testLocalVaultOverride() { $vault = $this->createMock(AbstractVault::class); @@ -78,9 +77,7 @@ public function testLocalVaultOverride() $this->assertEquals('newSecretValue', trim($tester->getDisplay(true))); } - /** - * @backupGlobals enabled - */ + #[BackupGlobals(true)] public function testOnlyLocalVaultContainsName() { $vault = $this->createMock(AbstractVault::class); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsSetCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsSetCommandTest.php index 678fb417c53cf..57db9c529cec6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsSetCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsSetCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Command\SecretsSetCommand; use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault; @@ -18,9 +19,7 @@ class SecretsSetCommandTest extends TestCase { - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions) { $vault = $this->createMock(AbstractVault::class); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php index 1b114ad491b61..e0e49fd2ede0c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; @@ -240,9 +241,7 @@ private function getBundle($path) return $bundle; } - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions) { $extractedMessagesWithDomains = [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationExtractCommandCompletionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationExtractCommandCompletionTest.php index a47b0913f2355..49874fe7c3d3f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationExtractCommandCompletionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationExtractCommandCompletionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Command\TranslationExtractCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; @@ -30,9 +31,7 @@ class TranslationExtractCommandCompletionTest extends TestCase private Filesystem $fs; private string $translationDir; - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions) { $tester = $this->createCommandCompletionTester(['messages' => ['foo' => 'foo']]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationExtractCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationExtractCommandTest.php index 22927d210c32e..89361e825ed11 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationExtractCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationExtractCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Command\TranslationExtractCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; @@ -177,9 +178,7 @@ public function testFilterDuplicateTransPaths() $this->assertEquals($expectedPaths, $filteredTransPaths); } - /** - * @dataProvider removeNoFillProvider - */ + #[DataProvider('removeNoFillProvider')] public function testRemoveNoFillTranslationsMethod($noFillCounter, $messages) { // Preparing mock diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/WorkflowDumpCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/WorkflowDumpCommandTest.php index 34009756a81e1..d7d17a9235564 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/WorkflowDumpCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/WorkflowDumpCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Command\WorkflowDumpCommand; use Symfony\Component\Console\Application; @@ -19,9 +20,7 @@ class WorkflowDumpCommandTest extends TestCase { - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions) { $application = new Application(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTestCase.php index d09fa8e4fd2df..f52a1d8dee39f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTestCase.php @@ -42,7 +42,7 @@ protected function tearDown(): void putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS'); } - /** @dataProvider getDescribeRouteCollectionTestData */ + #[DataProvider('getDescribeRouteCollectionTestData')] public function testDescribeRouteCollection(RouteCollection $routes, $expectedDescription) { $this->assertDescription($expectedDescription, $routes); @@ -53,7 +53,7 @@ public static function getDescribeRouteCollectionTestData(): array return static::getDescriptionTestData(ObjectsProvider::getRouteCollections()); } - /** @dataProvider getDescribeRouteCollectionWithHttpMethodFilterTestData */ + #[DataProvider('getDescribeRouteCollectionWithHttpMethodFilterTestData')] public function testDescribeRouteCollectionWithHttpMethodFilter(string $httpMethod, RouteCollection $routes, $expectedDescription) { $this->assertDescription($expectedDescription, $routes, ['method' => $httpMethod]); @@ -68,7 +68,7 @@ public static function getDescribeRouteCollectionWithHttpMethodFilterTestData(): } } - /** @dataProvider getDescribeRouteTestData */ + #[DataProvider('getDescribeRouteTestData')] public function testDescribeRoute(Route $route, $expectedDescription) { $this->assertDescription($expectedDescription, $route); @@ -79,7 +79,7 @@ public static function getDescribeRouteTestData(): array return static::getDescriptionTestData(ObjectsProvider::getRoutes()); } - /** @dataProvider getDescribeContainerParametersTestData */ + #[DataProvider('getDescribeContainerParametersTestData')] public function testDescribeContainerParameters(ParameterBag $parameters, $expectedDescription) { $this->assertDescription($expectedDescription, $parameters); @@ -90,7 +90,7 @@ public static function getDescribeContainerParametersTestData(): array return static::getDescriptionTestData(ObjectsProvider::getContainerParameters()); } - /** @dataProvider getDescribeContainerBuilderTestData */ + #[DataProvider('getDescribeContainerBuilderTestData')] public function testDescribeContainerBuilder(ContainerBuilder $builder, $expectedDescription, array $options) { $this->assertDescription($expectedDescription, $builder, $options); @@ -101,9 +101,7 @@ public static function getDescribeContainerBuilderTestData(): array return static::getContainerBuilderDescriptionTestData(ObjectsProvider::getContainerBuilders()); } - /** - * @dataProvider getDescribeContainerExistingClassDefinitionTestData - */ + #[DataProvider('getDescribeContainerExistingClassDefinitionTestData')] public function testDescribeContainerExistingClassDefinition(Definition $definition, $expectedDescription) { $this->assertDescription($expectedDescription, $definition); @@ -114,7 +112,7 @@ public static function getDescribeContainerExistingClassDefinitionTestData(): ar return static::getDescriptionTestData(ObjectsProvider::getContainerDefinitionsWithExistingClasses()); } - /** @dataProvider getDescribeContainerDefinitionTestData */ + #[DataProvider('getDescribeContainerDefinitionTestData')] public function testDescribeContainerDefinition(Definition $definition, $expectedDescription) { $this->assertDescription($expectedDescription, $definition); @@ -125,7 +123,7 @@ public static function getDescribeContainerDefinitionTestData(): array return static::getDescriptionTestData(ObjectsProvider::getContainerDefinitions()); } - /** @dataProvider getDescribeContainerDefinitionWithArgumentsShownTestData */ + #[DataProvider('getDescribeContainerDefinitionWithArgumentsShownTestData')] public function testDescribeContainerDefinitionWithArgumentsShown(Definition $definition, $expectedDescription) { $this->assertDescription($expectedDescription, $definition, []); @@ -145,7 +143,7 @@ public static function getDescribeContainerDefinitionWithArgumentsShownTestData( return static::getDescriptionTestData($definitionsWithArgs); } - /** @dataProvider getDescribeContainerAliasTestData */ + #[DataProvider('getDescribeContainerAliasTestData')] public function testDescribeContainerAlias(Alias $alias, $expectedDescription) { $this->assertDescription($expectedDescription, $alias); @@ -156,7 +154,7 @@ public static function getDescribeContainerAliasTestData(): array return static::getDescriptionTestData(ObjectsProvider::getContainerAliases()); } - /** @dataProvider getDescribeContainerDefinitionWhichIsAnAliasTestData */ + #[DataProvider('getDescribeContainerDefinitionWhichIsAnAliasTestData')] public function testDescribeContainerDefinitionWhichIsAnAlias(Alias $alias, $expectedDescription, ContainerBuilder $builder, $options = []) { $this->assertDescription($expectedDescription, $builder, $options); @@ -215,7 +213,7 @@ public static function getDescribeContainerParameterTestData(): array return $data; } - /** @dataProvider getDescribeEventDispatcherTestData */ + #[DataProvider('getDescribeEventDispatcherTestData')] public function testDescribeEventDispatcher(EventDispatcher $eventDispatcher, $expectedDescription, array $options) { $this->assertDescription($expectedDescription, $eventDispatcher, $options); @@ -226,7 +224,7 @@ public static function getDescribeEventDispatcherTestData(): array return static::getEventDispatcherDescriptionTestData(ObjectsProvider::getEventDispatchers()); } - /** @dataProvider getDescribeCallableTestData */ + #[DataProvider('getDescribeCallableTestData')] public function testDescribeCallable($callable, $expectedDescription) { $this->assertDescription($expectedDescription, $callable); @@ -250,7 +248,7 @@ public static function getDescribeDeprecatedCallableTestData(): array return static::getDescriptionTestData(ObjectsProvider::getDeprecatedCallables()); } - /** @dataProvider getClassDescriptionTestData */ + #[DataProvider('getClassDescriptionTestData')] public function testGetClassDescription($object, $expectedDescription) { $this->assertEquals($expectedDescription, $this->getDescriptor()->getClassDescription($object)); @@ -266,9 +264,7 @@ public static function getClassDescriptionTestData(): array ]; } - /** - * @dataProvider getDeprecationsTestData - */ + #[DataProvider('getDeprecationsTestData')] public function testGetDeprecations(ContainerBuilder $builder, $expectedDescription) { $this->assertDescription($expectedDescription, $builder, ['deprecations' => true]); @@ -357,7 +353,7 @@ private static function getEventDispatcherDescriptionTestData(array $objects): a return $data; } - /** @dataProvider getDescribeContainerBuilderWithPriorityTagsTestData */ + #[DataProvider('getDescribeContainerBuilderWithPriorityTagsTestData')] public function testDescribeContainerBuilderWithPriorityTags(ContainerBuilder $builder, $expectedDescription, array $options) { $this->assertDescription($expectedDescription, $builder, $options); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/TextDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/TextDescriptorTest.php index 34e16f5e42eff..0dc4bb18bc5ab 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/TextDescriptorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/TextDescriptorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Console\Descriptor\TextDescriptor; use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter; use Symfony\Component\Routing\Route; @@ -45,7 +46,7 @@ public static function getDescribeRouteWithControllerLinkTestData() return $getDescribeData; } - /** @dataProvider getDescribeRouteWithControllerLinkTestData */ + #[DataProvider('getDescribeRouteWithControllerLinkTestData')] public function testDescribeRouteWithControllerLink(Route $route, $expectedDescription) { static::$fileLinkFormatter = new FileLinkFormatter('myeditor://open?file=%f&line=%l'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php index 6ad0113fa0b69..f778aa4be00ae 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\DependencyInjection\Container; @@ -389,9 +391,7 @@ public function testdenyAccessUnlessGranted() } } - /** - * @dataProvider provideDenyAccessUnlessGrantedSetsAttributesAsArray - */ + #[DataProvider('provideDenyAccessUnlessGrantedSetsAttributesAsArray')] public function testdenyAccessUnlessGrantedSetsAttributesAsArray($attribute, $exceptionAttributes) { $authorizationChecker = $this->createMock(AuthorizationCheckerInterface::class); @@ -526,9 +526,7 @@ public function testRedirectToRoute() $this->assertSame(302, $response->getStatusCode()); } - /** - * @runInSeparateProcess - */ + #[RunInSeparateProcess] public function testAddFlash() { $flashBag = new FlashBag(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php index 161424e0e43ee..55f3b33c300fb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Controller\RedirectController; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\HttpFoundation\ParameterBag; @@ -60,9 +61,7 @@ public function testEmptyRoute() } } - /** - * @dataProvider provider - */ + #[DataProvider('provider')] public function testRoute($permanent, $keepRequestMethod, $keepQueryParams, $ignoreAttributes, $expectedCode, $expectedAttributes) { $request = new Request(); @@ -255,9 +254,7 @@ public static function urlRedirectProvider(): array ]; } - /** - * @dataProvider urlRedirectProvider - */ + #[DataProvider('urlRedirectProvider')] public function testUrlRedirect($scheme, $httpPort, $httpsPort, $requestScheme, $requestPort, $expectedPort) { $host = 'www.example.com'; @@ -287,9 +284,7 @@ public static function pathQueryParamsProvider(): array ]; } - /** - * @dataProvider pathQueryParamsProvider - */ + #[DataProvider('pathQueryParamsProvider')] public function testPathQueryParams($expectedUrl, $path, $queryString) { $scheme = 'http'; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php index 5a2215009dc44..12dfc085dea42 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector; use Symfony\Bundle\FrameworkBundle\DataCollector\TemplateAwareDataCollectorInterface; @@ -98,9 +99,7 @@ public static function getTemplate(): string }]; } - /** - * @dataProvider provideValidCollectorWithTemplateUsingAutoconfigure - */ + #[DataProvider('provideValidCollectorWithTemplateUsingAutoconfigure')] public function testValidCollectorWithTemplateUsingAutoconfigure(TemplateAwareDataCollectorInterface $dataCollector) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index c8142e98ab1a7..9bf8d55936cb1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -12,6 +12,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection; use Doctrine\DBAL\Connection; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration; use Symfony\Bundle\FullStack; @@ -61,9 +62,7 @@ public function getTestValidSessionName() ]; } - /** - * @dataProvider getTestInvalidSessionName - */ + #[DataProvider('getTestInvalidSessionName')] public function testInvalidSessionName($sessionName) { $processor = new Processor(); @@ -153,9 +152,7 @@ public function testAssetMapperCanBeEnabled() $this->assertEquals($defaultConfig, $config['asset_mapper']); } - /** - * @dataProvider provideImportmapPolyfillTests - */ + #[DataProvider('provideImportmapPolyfillTests')] public function testAssetMapperPolyfillValue(mixed $polyfillValue, bool $isValid, mixed $expected) { $processor = new Processor(); @@ -189,9 +186,7 @@ public static function provideImportmapPolyfillTests() yield [false, true, false]; } - /** - * @dataProvider provideValidAssetsPackageNameConfigurationTests - */ + #[DataProvider('provideValidAssetsPackageNameConfigurationTests')] public function testValidAssetsPackageNameConfiguration($packageName) { $processor = new Processor(); @@ -221,9 +216,7 @@ public static function provideValidAssetsPackageNameConfigurationTests(): array ]; } - /** - * @dataProvider provideInvalidAssetConfigurationTests - */ + #[DataProvider('provideInvalidAssetConfigurationTests')] public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMessage) { $processor = new Processor(); @@ -275,9 +268,7 @@ public static function provideInvalidAssetConfigurationTests(): iterable yield [$createPackageConfig($config), 'You cannot use both "version" and "json_manifest_path" at the same time under "assets" packages.']; } - /** - * @dataProvider provideValidLockConfigurationTests - */ + #[DataProvider('provideValidLockConfigurationTests')] public function testValidLockConfiguration($lockConfig, $processedConfig) { $processor = new Processor(); @@ -375,9 +366,7 @@ public function testLockMergeConfigs() ); } - /** - * @dataProvider provideValidSemaphoreConfigurationTests - */ + #[DataProvider('provideValidSemaphoreConfigurationTests')] public function testValidSemaphoreConfiguration($semaphoreConfig, $processedConfig) { $processor = new Processor(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php index b5f5f1ef5dc95..f7aad3925f434 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection; +use PHPUnit\Framework\Attributes\DataProvider; use Psr\Cache\CacheItemPoolInterface; use Psr\Log\LoggerAwareInterface; use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension; @@ -1934,9 +1935,7 @@ public function testRedisTagAwareAdapter() } } - /** - * @dataProvider appRedisTagAwareConfigProvider - */ + #[DataProvider('appRedisTagAwareConfigProvider')] public function testAppRedisTagAwareAdapter(string $configFile) { $container = $this->createContainerFromFile($configFile); @@ -1980,9 +1979,7 @@ public function testCacheTaggableTagAppliedToPools() } } - /** - * @dataProvider appRedisTagAwareConfigProvider - */ + #[DataProvider('appRedisTagAwareConfigProvider')] public function testCacheTaggableTagAppliedToRedisAwareAppPool(string $configFile) { $container = $this->createContainerFromFile($configFile); @@ -2222,9 +2219,7 @@ public static function provideMailer(): iterable ]; } - /** - * @dataProvider provideMailer - */ + #[DataProvider('provideMailer')] public function testMailer(string $configFile, array $expectedTransports, array $expectedRecipients, array $expectedAllowedRecipients) { $container = $this->createContainerFromFile($configFile); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php index c4f67c2f12ebe..d3c1f8ef4bfe1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -135,9 +136,7 @@ public function testWorkflowValidationStateMachine() }); } - /** - * @dataProvider provideWorkflowValidationCustomTests - */ + #[DataProvider('provideWorkflowValidationCustomTests')] public function testWorkflowValidationCustomBroken(string $class, string $message) { $this->expectException(InvalidConfigurationException::class); @@ -431,9 +430,7 @@ public function testRateLimiterCompoundPolicyInvalidLimiters() }); } - /** - * @dataProvider emailValidationModeProvider - */ + #[DataProvider('emailValidationModeProvider')] public function testValidatorEmailValidationMode(string $mode) { $this->expectNotToPerformAssertions(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1_link.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1_link.txt index ad7a4c8c844fb..b44fb4dbd3e86 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1_link.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1_link.txt @@ -10,7 +10,7 @@ | Method | GET|HEAD | | Requirements | name: [a-z]+ | | Class | Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub | -| Defaults | _controller: ]8;;myeditor://open?file=[:file:]&line=58\Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\MyController::__invoke()]8;;\ | +| Defaults | _controller: ]8;;myeditor://open?file=[:file:]&line=59\Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\MyController::__invoke()]8;;\ | | | name: Joseph | | Options | compiler_class: Symfony\Component\Routing\RouteCompiler | | | opt1: val1 | diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2_link.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2_link.txt index 8e3fe4ca7d65f..f033787a77146 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2_link.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2_link.txt @@ -10,7 +10,7 @@ | Method | PUT|POST | | Requirements | NO CUSTOM | | Class | Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub | -| Defaults | _controller: ]8;;myeditor://open?file=[:file:]&line=58\Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\MyController::__invoke()]8;;\ | +| Defaults | _controller: ]8;;myeditor://open?file=[:file:]&line=59\Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\MyController::__invoke()]8;;\ | | Options | compiler_class: Symfony\Component\Routing\RouteCompiler | | | opt1: val1 | | | opt2: val2 | diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AbstractAttributeRoutingTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AbstractAttributeRoutingTestCase.php index 5166c8dda4384..842d7268f7355 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AbstractAttributeRoutingTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AbstractAttributeRoutingTestCase.php @@ -11,13 +11,12 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\HttpFoundation\Request; abstract class AbstractAttributeRoutingTestCase extends AbstractWebTestCase { - /** - * @dataProvider getRoutes - */ + #[DataProvider('getRoutes')] public function testAnnotatedController(string $path, string $expectedValue) { $client = $this->createClient(['test_case' => $this->getTestCaseApp(), 'root_config' => 'config.yml']); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ApiAttributesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ApiAttributesTest.php index 4848976aede71..313c6d3868b6e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ApiAttributesTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ApiAttributesTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; @@ -21,9 +22,7 @@ class ApiAttributesTest extends AbstractWebTestCase { - /** - * @dataProvider mapQueryStringProvider - */ + #[DataProvider('mapQueryStringProvider')] public function testMapQueryString(string $uri, array $query, string $expectedResponse, int $expectedStatusCode) { $client = self::createClient(['test_case' => 'ApiAttributesTest']); @@ -214,9 +213,7 @@ public static function mapQueryStringProvider(): iterable ]; } - /** - * @dataProvider mapRequestPayloadProvider - */ + #[DataProvider('mapRequestPayloadProvider')] public function testMapRequestPayload(string $uri, string $format, array $parameters, ?string $content, callable $responseAssertion, int $expectedStatusCode) { $client = self::createClient(['test_case' => 'ApiAttributesTest']); @@ -603,7 +600,7 @@ public static function mapRequestPayloadProvider(): iterable self::assertIsArray($json['violations'] ?? null); self::assertCount(1, $json['violations']); self::assertSame('approved', $json['violations'][0]['propertyPath'] ?? null); -}, + }, 'expectedStatusCode' => 422, ]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php index a2966b5a244b6..53e8b5c48778b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\Group; use Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Cache\Adapter\FilesystemAdapter; @@ -19,9 +20,7 @@ use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; use Symfony\Component\Finder\SplFileInfo; -/** - * @group functional - */ +#[Group('functional')] class CachePoolClearCommandTest extends AbstractWebTestCase { protected function setUp(): void diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolListCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolListCommandTest.php index eec48402628b4..6dcbc4294e945 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolListCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolListCommandTest.php @@ -11,13 +11,12 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\Group; use Symfony\Bundle\FrameworkBundle\Command\CachePoolListCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; -/** - * @group functional - */ +#[Group('functional')] class CachePoolListCommandTest extends AbstractWebTestCase { protected function setUp(): void diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php index 23f4a116ef341..64829949a9932 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php @@ -11,6 +11,9 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; +use PHPUnit\Framework\Error\Warning; use Symfony\Component\Cache\Adapter\AdapterInterface; use Symfony\Component\Cache\Adapter\RedisAdapter; use Symfony\Component\Cache\Adapter\TagAwareAdapter; @@ -24,18 +27,15 @@ public function testCachePools() $this->doTestCachePools([], AdapterInterface::class); } - /** - * @requires extension redis - * - * @group integration - */ + #[RequiresPhpExtension('redis')] + #[Group('integration')] public function testRedisCachePools() { $this->skipIfRedisUnavailable(); try { $this->doTestCachePools(['root_config' => 'redis_config.yml', 'environment' => 'redis_cache'], RedisAdapter::class); - } catch (\PHPUnit\Framework\Error\Warning $e) { + } catch (Warning $e) { if (!str_starts_with($e->getMessage(), 'unable to connect to')) { throw $e; } @@ -48,18 +48,15 @@ public function testRedisCachePools() } } - /** - * @requires extension redis - * - * @group integration - */ + #[RequiresPhpExtension('redis')] + #[Group('integration')] public function testRedisCustomCachePools() { $this->skipIfRedisUnavailable(); try { $this->doTestCachePools(['root_config' => 'redis_custom_config.yml', 'environment' => 'custom_redis_cache'], RedisAdapter::class); - } catch (\PHPUnit\Framework\Error\Warning $e) { + } catch (Warning $e) { if (!str_starts_with($e->getMessage(), 'unable to connect to')) { throw $e; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php index 1819e7f4eae4f..6a06e22d7141e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php @@ -11,6 +11,9 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\TestWith; use Symfony\Bundle\FrameworkBundle\Command\ConfigDebugCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Exception\InvalidArgumentException; @@ -19,15 +22,11 @@ use Symfony\Component\Console\Tester\CommandCompletionTester; use Symfony\Component\Console\Tester\CommandTester; -/** - * @group functional - */ +#[Group('functional')] class ConfigDebugCommandTest extends AbstractWebTestCase { - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testShowList(bool $debug) { $tester = $this->createCommandTester($debug); @@ -44,10 +43,8 @@ public function testShowList(bool $debug) $this->assertStringContainsString(' test_dump', $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpKernelExtension(bool $debug) { $tester = $this->createCommandTester($debug); @@ -58,10 +55,8 @@ public function testDumpKernelExtension(bool $debug) $this->assertStringContainsString(' foo: bar', $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpBundleName(bool $debug) { $tester = $this->createCommandTester($debug); @@ -71,10 +66,8 @@ public function testDumpBundleName(bool $debug) $this->assertStringContainsString('custom: foo', $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpBundleOption(bool $debug) { $tester = $this->createCommandTester($debug); @@ -84,10 +77,8 @@ public function testDumpBundleOption(bool $debug) $this->assertStringContainsString('foo', $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpWithoutTitleIsValidJson(bool $debug) { $tester = $this->createCommandTester($debug); @@ -97,10 +88,8 @@ public function testDumpWithoutTitleIsValidJson(bool $debug) $this->assertJson($tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpWithUnsupportedFormat(bool $debug) { $tester = $this->createCommandTester($debug); @@ -114,10 +103,8 @@ public function testDumpWithUnsupportedFormat(bool $debug) ]); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testParametersValuesAreResolved(bool $debug) { $tester = $this->createCommandTester($debug); @@ -128,10 +115,8 @@ public function testParametersValuesAreResolved(bool $debug) $this->assertStringContainsString('secret: test', $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testParametersValuesAreFullyResolved(bool $debug) { $tester = $this->createCommandTester($debug); @@ -144,10 +129,8 @@ public function testParametersValuesAreFullyResolved(bool $debug) $this->assertStringContainsString('ide: '.$debug ? ($_ENV['SYMFONY_IDE'] ?? $_SERVER['SYMFONY_IDE'] ?? 'null') : 'null', $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDefaultParameterValueIsResolvedIfConfigIsExisting(bool $debug) { $tester = $this->createCommandTester($debug); @@ -158,10 +141,8 @@ public function testDefaultParameterValueIsResolvedIfConfigIsExisting(bool $debu $this->assertStringContainsString(\sprintf("dsn: 'file:%s/profiler'", $kernelCacheDir), $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpExtensionConfigWithoutBundle(bool $debug) { $tester = $this->createCommandTester($debug); @@ -171,10 +152,8 @@ public function testDumpExtensionConfigWithoutBundle(bool $debug) $this->assertStringContainsString('enabled: true', $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpUndefinedBundleOption(bool $debug) { $tester = $this->createCommandTester($debug); @@ -183,10 +162,8 @@ public function testDumpUndefinedBundleOption(bool $debug) $this->assertStringContainsString('Unable to find configuration for "test.foo"', $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpWithPrefixedEnv(bool $debug) { $tester = $this->createCommandTester($debug); @@ -195,10 +172,8 @@ public function testDumpWithPrefixedEnv(bool $debug) $this->assertStringContainsString("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpFallsBackToDefaultConfigAndResolvesParameterValue(bool $debug) { $tester = $this->createCommandTester($debug); @@ -208,10 +183,8 @@ public function testDumpFallsBackToDefaultConfigAndResolvesParameterValue(bool $ $this->assertStringContainsString('foo: bar', $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpFallsBackToDefaultConfigAndResolvesEnvPlaceholder(bool $debug) { $tester = $this->createCommandTester($debug); @@ -221,10 +194,8 @@ public function testDumpFallsBackToDefaultConfigAndResolvesEnvPlaceholder(bool $ $this->assertStringContainsString("baz: '%env(BAZ)%'", $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpThrowsExceptionWhenDefaultConfigFallbackIsImpossible(bool $debug) { $this->expectException(\LogicException::class); @@ -234,9 +205,7 @@ public function testDumpThrowsExceptionWhenDefaultConfigFallbackIsImpossible(boo $tester->execute(['name' => 'ExtensionWithoutConfigTestBundle']); } - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(bool $debug, array $input, array $expectedSuggestions) { $application = $this->createApplication($debug); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php index a16d8e0463fb8..f630173c7d2d4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php @@ -11,6 +11,9 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\TestWith; use Symfony\Bundle\FrameworkBundle\Command\ConfigDumpReferenceCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\ArrayInput; @@ -18,15 +21,11 @@ use Symfony\Component\Console\Tester\CommandCompletionTester; use Symfony\Component\Console\Tester\CommandTester; -/** - * @group functional - */ +#[Group('functional')] class ConfigDumpReferenceCommandTest extends AbstractWebTestCase { - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testShowList(bool $debug) { $tester = $this->createCommandTester($debug); @@ -43,10 +42,8 @@ public function testShowList(bool $debug) $this->assertStringContainsString(' test_dump', $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpKernelExtension(bool $debug) { $tester = $this->createCommandTester($debug); @@ -57,10 +54,8 @@ public function testDumpKernelExtension(bool $debug) $this->assertStringContainsString(' bar', $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpBundleName(bool $debug) { $tester = $this->createCommandTester($debug); @@ -71,10 +66,8 @@ public function testDumpBundleName(bool $debug) $this->assertStringContainsString(' custom:', $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpExtensionConfigWithoutBundle(bool $debug) { $tester = $this->createCommandTester($debug); @@ -84,10 +77,8 @@ public function testDumpExtensionConfigWithoutBundle(bool $debug) $this->assertStringContainsString('enabled: true', $tester->getDisplay()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpAtPath(bool $debug) { $tester = $this->createCommandTester($debug); @@ -108,10 +99,8 @@ public function testDumpAtPath(bool $debug) , $tester->getDisplay(true)); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testDumpAtPathXml(bool $debug) { $tester = $this->createCommandTester($debug); @@ -125,9 +114,7 @@ public function testDumpAtPathXml(bool $debug) $this->assertStringContainsString('[ERROR] The "path" option is only available for the "yaml" format.', $tester->getDisplay()); } - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(bool $debug, array $input, array $expectedSuggestions) { $application = $this->createApplication($debug); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php index 9b70c7bb34819..36e730d0a1bef 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BackslashClass; use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ContainerExcluded; @@ -18,9 +20,7 @@ use Symfony\Component\Console\Tester\CommandCompletionTester; use Symfony\Component\HttpKernel\HttpKernelInterface; -/** - * @group functional - */ +#[Group('functional')] class ContainerDebugCommandTest extends AbstractWebTestCase { public function testDumpContainerIfNotExists() @@ -113,9 +113,7 @@ public function testExcludedService() $this->assertStringNotContainsString(ContainerExcluded::class, $tester->getDisplay()); } - /** - * @dataProvider provideIgnoreBackslashWhenFindingService - */ + #[DataProvider('provideIgnoreBackslashWhenFindingService')] public function testIgnoreBackslashWhenFindingService(string $validServiceId) { static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']); @@ -282,9 +280,7 @@ public static function provideIgnoreBackslashWhenFindingService(): array ]; } - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions, array $notExpectedSuggestions = []) { static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml', 'debug' => true]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerLintCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerLintCommandTest.php index f0b6b4bd57b07..4cb989af31350 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerLintCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerLintCommandTest.php @@ -11,19 +11,17 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; -/** - * @group functional - */ +#[Group('functional')] class ContainerLintCommandTest extends AbstractWebTestCase { private Application $application; - /** - * @dataProvider containerLintProvider - */ + #[DataProvider('containerLintProvider')] public function testLintContainer(string $configFile, bool $resolveEnvVars, int $expectedExitCode, string $expectedOutput) { $kernel = static::createKernel([ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php index b43a12ed6c9d5..de94a1e718eff 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Command\DebugAutowiringCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; @@ -20,9 +22,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Routing\RouterInterface; -/** - * @group functional - */ +#[Group('functional')] class DebugAutowiringCommandTest extends AbstractWebTestCase { public function testBasicFunctionality() @@ -116,9 +116,7 @@ public function testNotConfusedByClassAliases() $this->assertStringContainsString(ClassAliasExampleClass::class, $tester->getDisplay()); } - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions) { $kernel = static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php index 48d5c327a3986..b26601af6bb9e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php @@ -11,11 +11,11 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; + class FragmentTest extends AbstractWebTestCase { - /** - * @dataProvider getConfigs - */ + #[DataProvider('getConfigs')] public function testFragment($insulate) { $client = $this->createClient(['test_case' => 'Fragment', 'root_config' => 'config.yml', 'debug' => true]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/NotificationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/NotificationTest.php index 03b947a0fb909..7511591cb66de 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/NotificationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/NotificationTest.php @@ -11,11 +11,12 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\RequiresMethod; +use Symfony\Bundle\MercureBundle\MercureBundle; + final class NotificationTest extends AbstractWebTestCase { - /** - * @requires function \Symfony\Bundle\MercureBundle\MercureBundle::build - */ + #[RequiresMethod(MercureBundle::class, 'build')] public function testNotifierAssertion() { $client = $this->createClient(['test_case' => 'Notifier', 'root_config' => 'config.yml', 'debug' => true]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php index d7825979536e5..b5853dd1a381c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php @@ -11,11 +11,11 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; + class ProfilerTest extends AbstractWebTestCase { - /** - * @dataProvider getConfigs - */ + #[DataProvider('getConfigs')] public function testProfilerIsDisabled($insulate) { $client = $this->createClient(['test_case' => 'Profiler', 'root_config' => 'config.yml']); @@ -36,9 +36,7 @@ public function testProfilerIsDisabled($insulate) $this->assertNull($client->getProfile()); } - /** - * @dataProvider getConfigs - */ + #[DataProvider('getConfigs')] public function testProfilerCollectParameter($insulate) { $client = $this->createClient(['test_case' => 'ProfilerCollectParameter', 'root_config' => 'config.yml']); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php index 61407880457ce..910e3b6f7901f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php @@ -11,13 +11,14 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\TestWith; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandCompletionTester; use Symfony\Component\Console\Tester\CommandTester; -/** - * @group functional - */ +#[Group('functional')] class RouterDebugCommandTest extends AbstractWebTestCase { private Application $application; @@ -89,21 +90,17 @@ public function testSearchWithThrow() $tester->execute(['name' => 'gerard'], ['interactive' => true]); } - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions) { $tester = new CommandCompletionTester($this->application->get('debug:router')); $this->assertSame($expectedSuggestions, $tester->complete($input)); } - /** - * @testWith ["txt"] - * ["xml"] - * ["json"] - * ["md"] - */ + #[TestWith(['txt'])] + #[TestWith(['xml'])] + #[TestWith(['json'])] + #[TestWith(['md'])] public function testShowAliases(string $format) { $tester = $this->createCommandTester(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RoutingConditionServiceTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RoutingConditionServiceTest.php index 4f4caa6eb1567..f1f4f14cf146f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RoutingConditionServiceTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RoutingConditionServiceTest.php @@ -11,11 +11,11 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; + class RoutingConditionServiceTest extends AbstractWebTestCase { - /** - * @dataProvider provideRoutes - */ + #[DataProvider('provideRoutes')] public function testCondition(int $code, string $path) { $client = static::createClient(['test_case' => 'RoutingConditionService']); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SecurityTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SecurityTest.php index c26fa717d9176..ab06b5f6c25eb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SecurityTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SecurityTest.php @@ -11,13 +11,12 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Security\Core\User\InMemoryUser; class SecurityTest extends AbstractWebTestCase { - /** - * @dataProvider getUsers - */ + #[DataProvider('getUsers')] public function testLoginUser(string $username, array $roles, ?string $firewallContext) { $user = new InMemoryUser($username, 'the-password', $roles); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php index 4c1b92ccf539f..88ea3230a8e3d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php @@ -11,13 +11,14 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; + class SessionTest extends AbstractWebTestCase { /** * Tests session attributes persist. - * - * @dataProvider getConfigs */ + #[DataProvider('getConfigs')] public function testWelcome($config, $insulate) { $client = $this->createClient(['test_case' => 'Session', 'root_config' => $config]); @@ -48,9 +49,8 @@ public function testWelcome($config, $insulate) /** * Tests flash messages work in practice. - * - * @dataProvider getConfigs */ + #[DataProvider('getConfigs')] public function testFlash($config, $insulate) { $client = $this->createClient(['test_case' => 'Session', 'root_config' => $config]); @@ -72,9 +72,8 @@ public function testFlash($config, $insulate) /** * See if two separate insulated clients can run without * polluting each other's session data. - * - * @dataProvider getConfigs */ + #[DataProvider('getConfigs')] public function testTwoClients($config, $insulate) { // start first client @@ -128,9 +127,7 @@ public function testTwoClients($config, $insulate) $this->assertStringContainsString('Welcome back client2, nice to meet you.', $crawler2->text()); } - /** - * @dataProvider getConfigs - */ + #[DataProvider('getConfigs')] public function testCorrectCacheControlHeadersForCacheableAction($config, $insulate) { $client = $this->createClient(['test_case' => 'Session', 'root_config' => $config]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SluggerLocaleAwareTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SluggerLocaleAwareTest.php index 76901246138b6..d09f969b065a7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SluggerLocaleAwareTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SluggerLocaleAwareTest.php @@ -11,16 +11,14 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Slugger\SlugConstructArgService; -/** - * @group functional - */ +#[Group('functional')] class SluggerLocaleAwareTest extends AbstractWebTestCase { - /** - * @requires extension intl - */ + #[RequiresPhpExtension('intl')] public function testLocalizedSlugger() { $kernel = static::createKernel(['test_case' => 'Slugger', 'root_config' => 'config.yml']); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/TestServiceContainerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/TestServiceContainerTest.php index fe7093081509f..8b8898ad84933 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/TestServiceContainerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/TestServiceContainerTest.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use Symfony\Bundle\FrameworkBundle\Test\TestContainer; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestServiceContainer\NonPublicService; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestServiceContainer\PrivateService; @@ -68,17 +70,13 @@ public function testSetDecoratedService() $this->assertSame($service, $container->get('decorated')->inner); } - /** - * @doesNotPerformAssertions - */ + #[DoesNotPerformAssertions] public function testBootKernel() { static::bootKernel(['test_case' => 'TestServiceContainer']); } - /** - * @depends testBootKernel - */ + #[Depends('testBootKernel')] public function testKernelIsNotInitialized() { self::assertNull(self::$class); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/TranslationDebugCommandTest.php index 5e396440cacf4..1d7e2952b6fa5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/TranslationDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/TranslationDebugCommandTest.php @@ -11,13 +11,12 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\Group; use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; -/** - * @group functional - */ +#[Group('functional')] class TranslationDebugCommandTest extends AbstractWebTestCase { private Application $application; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php index d2c0215634b2a..f46522a97234c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Routing; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Symfony\Bundle\FrameworkBundle\Routing\Router; @@ -438,9 +439,7 @@ public function testExceptionOnNonStringParameterWithSfContainer() $router->getRouteCollection(); } - /** - * @dataProvider getNonStringValues - */ + #[DataProvider('getNonStringValues')] public function testDefaultValuesAsNonStrings($value) { $routes = new RouteCollection(); @@ -455,9 +454,7 @@ public function testDefaultValuesAsNonStrings($value) $this->assertSame($value, $route->getDefault('foo')); } - /** - * @dataProvider getNonStringValues - */ + #[DataProvider('getNonStringValues')] public function testDefaultValuesAsNonStringsWithSfContainer($value) { $routes = new RouteCollection(); @@ -525,9 +522,7 @@ public static function getNonStringValues() return [[null], [false], [true], [new \stdClass()], [['foo', 'bar']], [[[]]]]; } - /** - * @dataProvider getContainerParameterForRoute - */ + #[DataProvider('getContainerParameterForRoute')] public function testCacheValidityWithContainerParameters($parameter) { $cacheDir = tempnam(sys_get_temp_dir(), 'sf_router_'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Secrets/SodiumVaultTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Secrets/SodiumVaultTest.php index f91f4bceda5f4..6d050386b9858 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Secrets/SodiumVaultTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Secrets/SodiumVaultTest.php @@ -11,14 +11,13 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Secrets; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Secrets\SodiumVault; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\String\LazyString; -/** - * @requires extension sodium - */ +#[RequiresPhpExtension('sodium')] class SodiumVaultTest extends TestCase { private string $secretsDir; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php index fd65b18d830cf..a058d3628c081 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php @@ -12,6 +12,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Test; use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\Attributes\RequiresMethod; use PHPUnit\Framework\ExpectationFailedException; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -192,9 +193,7 @@ public function testAssertBrowserCookieValueSame() $this->getClientTester()->assertBrowserCookieValueSame('foo', 'babar', false, '/path'); } - /** - * @requires function \Symfony\Component\BrowserKit\History::isFirstPage - */ + #[RequiresMethod(History::class, 'isFirstPage')] public function testAssertBrowserHistoryIsOnFirstPage() { $this->createHistoryTester('isFirstPage', true)->assertBrowserHistoryIsOnFirstPage(); @@ -203,9 +202,7 @@ public function testAssertBrowserHistoryIsOnFirstPage() $this->createHistoryTester('isFirstPage', false)->assertBrowserHistoryIsOnFirstPage(); } - /** - * @requires function \Symfony\Component\BrowserKit\History::isFirstPage - */ + #[RequiresMethod(History::class, 'isFirstPage')] public function testAssertBrowserHistoryIsNotOnFirstPage() { $this->createHistoryTester('isFirstPage', false)->assertBrowserHistoryIsNotOnFirstPage(); @@ -214,9 +211,7 @@ public function testAssertBrowserHistoryIsNotOnFirstPage() $this->createHistoryTester('isFirstPage', true)->assertBrowserHistoryIsNotOnFirstPage(); } - /** - * @requires function \Symfony\Component\BrowserKit\History::isLastPage - */ + #[RequiresMethod(History::class, 'isLastPage')] public function testAssertBrowserHistoryIsOnLastPage() { $this->createHistoryTester('isLastPage', true)->assertBrowserHistoryIsOnLastPage(); @@ -225,9 +220,7 @@ public function testAssertBrowserHistoryIsOnLastPage() $this->createHistoryTester('isLastPage', false)->assertBrowserHistoryIsOnLastPage(); } - /** - * @requires function \Symfony\Component\BrowserKit\History::isLastPage - */ + #[RequiresMethod(History::class, 'isLastPage')] public function testAssertBrowserHistoryIsNotOnLastPage() { $this->createHistoryTester('isLastPage', false)->assertBrowserHistoryIsNotOnLastPage(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php index e481a965e717d..d5f5d88ebd67b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Translation; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Translation\Translator; use Symfony\Component\Config\Resource\DirectoryResource; @@ -130,7 +131,7 @@ public function testInvalidOptions() new Translator(new Container(), new MessageFormatter(), 'en', [], ['foo' => 'bar']); } - /** @dataProvider getDebugModeAndCacheDirCombinations */ + #[DataProvider('getDebugModeAndCacheDirCombinations')] public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $enableCache) { $someCatalogue = $this->getCatalogue('some_locale', []); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php index 743e1b3fbad16..d7a468c2d462d 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DataCollector; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\DataCollector\SecurityDataCollector; use Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener; @@ -78,7 +80,7 @@ public function testCollectWhenAuthenticationTokenIsNull() $this->assertNull($collector->getFirewall()); } - /** @dataProvider provideRoles */ + #[DataProvider('provideRoles')] public function testCollectAuthenticationTokenAndRoles(array $roles, array $normalizedRoles, array $inheritedRoles) { $tokenStorage = new TokenStorage(); @@ -186,9 +188,7 @@ public function testGetFirewallReturnsNull() $this->assertNull($collector->getFirewall()); } - /** - * @group time-sensitive - */ + #[Group('time-sensitive')] public function testGetListeners() { $request = new Request(); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Debug/TraceableFirewallListenerTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Debug/TraceableFirewallListenerTest.php index 6fbe45f41b01f..898517d0c8dd7 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Debug/TraceableFirewallListenerTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Debug/TraceableFirewallListenerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Debug; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener; use Symfony\Bundle\SecurityBundle\Security\FirewallMap; @@ -33,9 +34,7 @@ use Symfony\Component\Security\Http\Firewall\AuthenticatorManagerListener; use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class TraceableFirewallListenerTest extends TestCase { public function testOnKernelRequestRecordsListeners() diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/RegisterGlobalSecurityEventListenersPassTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/RegisterGlobalSecurityEventListenersPassTest.php index e6567e67d6f7d..bc95ab1f47db1 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/RegisterGlobalSecurityEventListenersPassTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/RegisterGlobalSecurityEventListenersPassTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Compiler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension; use Symfony\Bundle\SecurityBundle\SecurityBundle; @@ -50,9 +51,7 @@ protected function setUp(): void $securityBundle->build($this->container); } - /** - * @dataProvider providePropagatedEvents - */ + #[DataProvider('providePropagatedEvents')] public function testEventIsPropagated(string $configuredEvent, string $registeredEvent) { $this->container->loadFromExtension('security', [ diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php index 07cfd04af4228..4bf0429b97f53 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php @@ -233,9 +233,7 @@ public function testFirewalls() $configuration->getConfigTreeBuilder(); } - /** - * @dataProvider provideHideUserNotFoundData - */ + #[DataProvider('provideHideUserNotFoundData')] public function testExposeSecurityErrors(array $config, ExposeSecurityLevel $expectedExposeSecurityErrors) { $config = array_merge(static::$minimalConfig, $config); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php index be300e7526b82..2cce3b1fb69ab 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Security\Factory; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory; use Symfony\Component\DependencyInjection\ChildDefinition; @@ -25,9 +26,7 @@ protected function setUp(): void $this->container = new ContainerBuilder(); } - /** - * @dataProvider getFailureHandlers - */ + #[DataProvider('getFailureHandlers')] public function testDefaultFailureHandler($serviceId, $defaultHandlerInjection) { $options = [ @@ -68,9 +67,7 @@ public static function getFailureHandlers() ]; } - /** - * @dataProvider getSuccessHandlers - */ + #[DataProvider('getSuccessHandlers')] public function testDefaultSuccessHandler($serviceId, $defaultHandlerInjection) { $options = [ diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AccessTokenFactoryTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AccessTokenFactoryTest.php index 2f6e8e7f9513e..dc6c03bbd5e16 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AccessTokenFactoryTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AccessTokenFactoryTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Security\Factory; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\TestCase; @@ -422,9 +423,7 @@ public function testOidcUserInfoTokenHandlerConfigurationWithExistingClient() $this->assertEquals($expected, $container->getDefinition('security.access_token_handler.firewall1')->getArguments()); } - /** - * @dataProvider getOidcUserInfoConfiguration - */ + #[DataProvider('getOidcUserInfoConfiguration')] public function testOidcUserInfoTokenHandlerConfigurationWithBaseUri(array|string $configuration) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php index 55ad733597a82..7a9feccee1eb8 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FirewallListenerFactoryInterface; @@ -278,7 +279,7 @@ public function testRegisterAccessControlWithSpecifiedRequestMatcherService() $this->assertSame($requestMatcherId, (string) $args[0]); } - /** @dataProvider provideAdditionalRequestMatcherConstraints */ + #[DataProvider('provideAdditionalRequestMatcherConstraints')] public function testRegisterAccessControlWithRequestMatcherAndAdditionalOptionsThrowsInvalidException(array $additionalConstraints) { $container = $this->getRawContainer(); @@ -477,9 +478,7 @@ public function testDoNotRegisterTheUserProviderAliasWithMultipleProviders() $this->assertFalse($container->has(UserProviderInterface::class)); } - /** - * @dataProvider acceptableIpsProvider - */ + #[DataProvider('acceptableIpsProvider')] public function testAcceptableAccessControlIps($ips) { $container = $this->getRawContainer(); @@ -664,9 +663,7 @@ public static function provideEntryPointFirewalls(): iterable ], 'security.authenticator.guard.main.0']; } - /** - * @dataProvider provideEntryPointRequiredData - */ + #[DataProvider('provideEntryPointRequiredData')] public function testEntryPointRequired(array $firewall, string $messageRegex) { $container = $this->getRawContainer(); @@ -695,9 +692,7 @@ public static function provideEntryPointRequiredData(): iterable ]; } - /** - * @dataProvider provideConfigureCustomAuthenticatorData - */ + #[DataProvider('provideConfigureCustomAuthenticatorData')] public function testConfigureCustomAuthenticator(array $firewall, array $expectedAuthenticators) { $container = $this->getRawContainer(); @@ -770,9 +765,7 @@ public function testCompilesWithSessionListenerWithStatefulllFirewallWithAuthent $this->assertTrue($container->has('security.listener.session.'.$firewallId)); } - /** - * @dataProvider provideUserCheckerConfig - */ + #[DataProvider('provideUserCheckerConfig')] public function testUserCheckerWithAuthenticatorManager(array $config, string $expectedUserCheckerClass) { $container = $this->getRawContainer(); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlCustomAuthenticatorTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlCustomAuthenticatorTest.php index e57cda13ff78d..a473d8d19b829 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlCustomAuthenticatorTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlCustomAuthenticatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension; use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\Authenticator\CustomAuthenticator; @@ -20,9 +21,7 @@ class XmlCustomAuthenticatorTest extends TestCase { - /** - * @dataProvider provideXmlConfigurationFile - */ + #[DataProvider('provideXmlConfigurationFile')] public function testCustomProviderElement(string $configurationFile) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlCustomProviderTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlCustomProviderTest.php index a3f59fc299a24..a79e74a9f50e9 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlCustomProviderTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlCustomProviderTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension; use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider\CustomProvider; @@ -20,9 +21,7 @@ class XmlCustomProviderTest extends TestCase { - /** - * @dataProvider provideXmlConfigurationFile - */ + #[DataProvider('provideXmlConfigurationFile')] public function testCustomProviderElement(string $configurationFile) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AccessTokenTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AccessTokenTest.php index 75adf296110da..6a2e008423068 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AccessTokenTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AccessTokenTest.php @@ -20,6 +20,8 @@ use Jose\Component\Signature\Algorithm\ES256; use Jose\Component\Signature\JWSBuilder; use Jose\Component\Signature\Serializer\CompactSerializer as JwsCompactSerializer; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\HttpClient\Response\MockResponse; @@ -63,9 +65,7 @@ public function testDefaultFormEncodedBodySuccess() $this->assertSame(['message' => 'Welcome @dunglas!'], json_decode($response->getContent(), true)); } - /** - * @dataProvider defaultFormEncodedBodyFailureData - */ + #[DataProvider('defaultFormEncodedBodyFailureData')] public function testDefaultFormEncodedBodyFailure(array $parameters, array $headers) { $client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_body_default.yml']); @@ -99,9 +99,7 @@ public function testCustomFormEncodedBodySuccess() $this->assertSame(['message' => 'Good game @dunglas!'], json_decode($response->getContent(), true)); } - /** - * @dataProvider customFormEncodedBodyFailure - */ + #[DataProvider('customFormEncodedBodyFailure')] public function testCustomFormEncodedBodyFailure(array $parameters, array $headers) { $client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_body_custom.yml']); @@ -156,9 +154,7 @@ public function testMultipleAccessTokenExtractorSuccess() $this->assertSame(['message' => 'Welcome @dunglas!'], json_decode($response->getContent(), true)); } - /** - * @dataProvider defaultHeaderAccessTokenFailureData - */ + #[DataProvider('defaultHeaderAccessTokenFailureData')] public function testDefaultHeaderAccessTokenFailure(array $headers) { $client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_header_default.yml']); @@ -171,9 +167,7 @@ public function testDefaultHeaderAccessTokenFailure(array $headers) $this->assertSame('Bearer realm="My API",error="invalid_token",error_description="Invalid credentials."', $response->headers->get('WWW-Authenticate')); } - /** - * @dataProvider defaultMissingHeaderAccessTokenFailData - */ + #[DataProvider('defaultMissingHeaderAccessTokenFailData')] public function testDefaultMissingHeaderAccessTokenFail(array $headers) { $client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_header_default.yml']); @@ -195,9 +189,7 @@ public function testCustomHeaderAccessTokenSuccess() $this->assertSame(['message' => 'Good game @dunglas!'], json_decode($response->getContent(), true)); } - /** - * @dataProvider customHeaderAccessTokenFailure - */ + #[DataProvider('customHeaderAccessTokenFailure')] public function testCustomHeaderAccessTokenFailure(array $headers, int $errorCode) { $client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_header_custom.yml']); @@ -209,9 +201,7 @@ public function testCustomHeaderAccessTokenFailure(array $headers, int $errorCod $this->assertFalse($response->headers->has('WWW-Authenticate')); } - /** - * @dataProvider customMissingHeaderAccessTokenShouldFail - */ + #[DataProvider('customMissingHeaderAccessTokenShouldFail')] public function testCustomMissingHeaderAccessTokenShouldFail(array $headers) { $client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_header_custom.yml']); @@ -256,9 +246,7 @@ public function testDefaultQueryAccessTokenSuccess() $this->assertSame(['message' => 'Welcome @dunglas!'], json_decode($response->getContent(), true)); } - /** - * @dataProvider defaultQueryAccessTokenFailureData - */ + #[DataProvider('defaultQueryAccessTokenFailureData')] public function testDefaultQueryAccessTokenFailure(string $query) { $client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_query_default.yml']); @@ -292,9 +280,7 @@ public function testCustomQueryAccessTokenSuccess() $this->assertSame(['message' => 'Good game @dunglas!'], json_decode($response->getContent(), true)); } - /** - * @dataProvider customQueryAccessTokenFailure - */ + #[DataProvider('customQueryAccessTokenFailure')] public function testCustomQueryAccessTokenFailure(string $query) { $client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_query_custom.yml']); @@ -351,11 +337,8 @@ public function testCustomUserLoader() $this->assertSame(['message' => 'Welcome @dunglas!'], json_decode($response->getContent(), true)); } - /** - * @dataProvider validAccessTokens - * - * @requires extension openssl - */ + #[DataProvider('validAccessTokens')] + #[RequiresPhpExtension('openssl')] public function testOidcSuccess(callable $tokenFactory) { try { @@ -373,11 +356,8 @@ public function testOidcSuccess(callable $tokenFactory) $this->assertSame(['message' => 'Welcome @dunglas!'], json_decode($response->getContent(), true)); } - /** - * @dataProvider invalidAccessTokens - * - * @requires extension openssl - */ + #[DataProvider('invalidAccessTokens')] + #[RequiresPhpExtension('openssl')] public function testOidcFailure(callable $tokenFactory) { try { @@ -395,9 +375,7 @@ public function testOidcFailure(callable $tokenFactory) $this->assertSame('Bearer realm="My API",error="invalid_token",error_description="Invalid credentials."', $response->headers->get('WWW-Authenticate')); } - /** - * @requires extension openssl - */ + #[RequiresPhpExtension('openssl')] public function testOidcFailureWithJweEnforced() { $client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_oidc_jwe.yml']); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticatorTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticatorTest.php index b78f262cf5502..9a7f783253206 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticatorTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticatorTest.php @@ -11,11 +11,11 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; + class AuthenticatorTest extends AbstractWebTestCase { - /** - * @dataProvider provideEmails - */ + #[DataProvider('provideEmails')] public function testFirewallUserProvider($email, $withinFirewall) { $client = $this->createClient(['test_case' => 'Authenticator', 'root_config' => 'firewall_user_provider.yml']); @@ -31,9 +31,7 @@ public function testFirewallUserProvider($email, $withinFirewall) } } - /** - * @dataProvider provideEmails - */ + #[DataProvider('provideEmails')] public function testWithoutUserProvider($email) { $client = $this->createClient(['test_case' => 'Authenticator', 'root_config' => 'no_user_provider.yml']); @@ -51,9 +49,7 @@ public static function provideEmails(): iterable yield ['john@example.org', false]; } - /** - * @dataProvider provideEmailsWithFirewalls - */ + #[DataProvider('provideEmailsWithFirewalls')] public function testLoginUsersWithMultipleFirewalls(string $username, string $firewallContext) { $client = $this->createClient(['test_case' => 'Authenticator', 'root_config' => 'multiple_firewall_user_provider.yml']); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php index ee8cc60a4edd5..68c6b5d1c596b 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Response; @@ -19,9 +20,7 @@ class CsrfFormLoginTest extends AbstractWebTestCase { - /** - * @dataProvider provideClientOptions - */ + #[DataProvider('provideClientOptions')] public function testFormLoginAndLogoutWithCsrfTokens($options) { $client = $this->createClient($options); @@ -56,9 +55,7 @@ public function testFormLoginAndLogoutWithCsrfTokens($options) }); } - /** - * @dataProvider provideClientOptions - */ + #[DataProvider('provideClientOptions')] public function testFormLoginWithInvalidCsrfToken($options) { $client = $this->createClient($options); @@ -83,9 +80,7 @@ public function testFormLoginWithInvalidCsrfToken($options) }); } - /** - * @dataProvider provideClientOptions - */ + #[DataProvider('provideClientOptions')] public function testFormLoginWithCustomTargetPath($options) { $client = $this->createClient($options); @@ -103,9 +98,7 @@ public function testFormLoginWithCustomTargetPath($options) $this->assertStringContainsString('You\'re browsing to path "/foo".', $text); } - /** - * @dataProvider provideClientOptions - */ + #[DataProvider('provideClientOptions')] public function testFormLoginRedirectsToProtectedResourceAfterLogin($options) { $client = $this->createClient($options); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php index f6957f45a87b4..9b144664503a9 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php @@ -11,11 +11,12 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; + class FormLoginTest extends AbstractWebTestCase { - /** - * @dataProvider provideClientOptions - */ + #[DataProvider('provideClientOptions')] public function testFormLogin(array $options) { $client = $this->createClient($options); @@ -32,9 +33,7 @@ public function testFormLogin(array $options) $this->assertStringContainsString('You\'re browsing to path "/profile".', $text); } - /** - * @dataProvider provideClientOptions - */ + #[DataProvider('provideClientOptions')] public function testFormLogout(array $options) { $client = $this->createClient($options); @@ -65,9 +64,7 @@ public function testFormLogout(array $options) $this->assertSame($logoutLinks[1]->getUri(), $logoutLinks[5]->getUri()); } - /** - * @dataProvider provideClientOptions - */ + #[DataProvider('provideClientOptions')] public function testFormLoginWithCustomTargetPath(array $options) { $client = $this->createClient($options); @@ -85,9 +82,7 @@ public function testFormLoginWithCustomTargetPath(array $options) $this->assertStringContainsString('You\'re browsing to path "/foo".', $text); } - /** - * @dataProvider provideClientOptions - */ + #[DataProvider('provideClientOptions')] public function testFormLoginRedirectsToProtectedResourceAfterLogin(array $options) { $client = $this->createClient($options); @@ -106,9 +101,7 @@ public function testFormLoginRedirectsToProtectedResourceAfterLogin(array $optio $this->assertStringContainsString('You\'re browsing to path "/protected_resource".', $text); } - /** - * @group time-sensitive - */ + #[Group('time-sensitive')] public function testLoginThrottling() { $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => 'login_throttling.yml']); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php index 99ba311a26eb8..697272940c263 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php @@ -11,11 +11,12 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; + class LocalizedRoutesAsPathTest extends AbstractWebTestCase { - /** - * @dataProvider getLocales - */ + #[DataProvider('getLocales')] public function testLoginLogoutProcedure(string $locale) { $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes.yml']); @@ -34,11 +35,8 @@ public function testLoginLogoutProcedure(string $locale) $this->assertEquals('Homepage', $client->followRedirect()->text()); } - /** - * @group issue-32995 - * - * @dataProvider getLocales - */ + #[Group('issue-32995')] + #[DataProvider('getLocales')] public function testLoginFailureWithLocalizedFailurePath(string $locale) { $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => 'localized_form_failure_handler.yml']); @@ -52,9 +50,7 @@ public function testLoginFailureWithLocalizedFailurePath(string $locale) $this->assertRedirect($client->getResponse(), '/'.$locale.'/login'); } - /** - * @dataProvider getLocales - */ + #[DataProvider('getLocales')] public function testAccessRestrictedResource(string $locale) { $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes.yml']); @@ -63,9 +59,7 @@ public function testAccessRestrictedResource(string $locale) $this->assertRedirect($client->getResponse(), '/'.$locale.'/login'); } - /** - * @dataProvider getLocales - */ + #[DataProvider('getLocales')] public function testAccessRestrictedResourceWithForward(string $locale) { $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes_with_forward.yml']); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeCookieTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeCookieTest.php index 34fbca10843fa..cd82807ea5b54 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeCookieTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeCookieTest.php @@ -11,11 +11,12 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\HttpFoundation\ResponseHeaderBag; class RememberMeCookieTest extends AbstractWebTestCase { - /** @dataProvider getSessionRememberMeSecureCookieFlagAutoHttpsMap */ + #[DataProvider('getSessionRememberMeSecureCookieFlagAutoHttpsMap')] public function testSessionRememberMeSecureCookieFlagAuto($https, $expectedSecureFlag) { $client = $this->createClient(['test_case' => 'RememberMeCookie', 'root_config' => 'config.yml']); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeTest.php index 036069f070f6b..70e5f2b5e0ff6 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/RememberMeTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\RememberMeBundle\Security\UserChangingUserProvider; class RememberMeTest extends AbstractWebTestCase @@ -20,9 +21,7 @@ protected function setUp(): void UserChangingUserProvider::$changePassword = false; } - /** - * @dataProvider provideConfigs - */ + #[DataProvider('provideConfigs')] public function testRememberMe(array $options) { $client = $this->createClient(array_merge_recursive(['root_config' => 'config.yml', 'test_case' => 'RememberMe'], $options)); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php index 517253fdff94e..625c799f03cb3 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php @@ -11,11 +11,11 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; + class SecurityRoutingIntegrationTest extends AbstractWebTestCase { - /** - * @dataProvider provideConfigs - */ + #[DataProvider('provideConfigs')] public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous(array $options) { $client = $this->createClient($options); @@ -24,9 +24,7 @@ public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous(ar $this->assertRedirect($client->getResponse(), '/login'); } - /** - * @dataProvider provideConfigs - */ + #[DataProvider('provideConfigs')] public function testRoutingErrorIsExposedWhenNotProtected(array $options) { $client = $this->createClient($options); @@ -35,9 +33,7 @@ public function testRoutingErrorIsExposedWhenNotProtected(array $options) $this->assertEquals(404, $client->getResponse()->getStatusCode(), (string) $client->getResponse()); } - /** - * @dataProvider provideConfigs - */ + #[DataProvider('provideConfigs')] public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights(array $options) { $client = $this->createClient($options); @@ -52,9 +48,7 @@ public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWith $this->assertNotEquals(404, $client->getResponse()->getStatusCode()); } - /** - * @dataProvider provideConfigs - */ + #[DataProvider('provideConfigs')] public function testSecurityConfigurationForSingleIPAddress(array $options) { $allowedClient = $this->createClient($options, ['REMOTE_ADDR' => '10.10.10.10']); @@ -67,9 +61,7 @@ public function testSecurityConfigurationForSingleIPAddress(array $options) $this->assertRestricted($barredClient, '/secured-by-one-ip'); } - /** - * @dataProvider provideConfigs - */ + #[DataProvider('provideConfigs')] public function testSecurityConfigurationForMultipleIPAddresses(array $options) { $allowedClientA = $this->createClient($options, ['REMOTE_ADDR' => '1.1.1.1']); @@ -96,9 +88,7 @@ public function testSecurityConfigurationForMultipleIPAddresses(array $options) $this->assertRestricted($barredClient, '/secured-by-two-ips'); } - /** - * @dataProvider provideConfigs - */ + #[DataProvider('provideConfigs')] public function testSecurityConfigurationForExpression(array $options) { $allowedClient = $this->createClient($options, ['HTTP_USER_AGENT' => 'Firefox 1.0']); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php index 76987173bed5c..2225e8c62eda8 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php @@ -11,8 +11,11 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\TestWith; use Symfony\Bundle\SecurityBundle\Security; use Symfony\Bundle\SecurityBundle\Security\FirewallConfig; +use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AuthenticatorBundle\ApiAuthenticator; use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\SecuredPageBundle\Security\Core\User\ArrayUserProvider; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\JsonResponse; @@ -65,9 +68,7 @@ public function testUserAuthorizationChecker() $this->assertFalse($security->isGrantedForUser($offlineUser, 'ROLE_FOO')); } - /** - * @dataProvider userWillBeMarkedAsChangedIfRolesHasChangedProvider - */ + #[DataProvider('userWillBeMarkedAsChangedIfRolesHasChangedProvider')] public function testUserWillBeMarkedAsChangedIfRolesHasChanged(UserInterface $userWithAdminRole, UserInterface $userWithoutAdminRole) { $client = $this->createClient(['test_case' => 'AbstractTokenCompareRoles', 'root_config' => 'config.yml']); @@ -108,10 +109,8 @@ public static function userWillBeMarkedAsChangedIfRolesHasChangedProvider(): arr ]; } - /** - * @testWith ["form_login"] - * ["Symfony\\Bundle\\SecurityBundle\\Tests\\Functional\\Bundle\\AuthenticatorBundle\\ApiAuthenticator"] - */ + #[TestWith(['form_login'])] + #[TestWith([ApiAuthenticator::class])] public function testLogin(string $authenticator) { $client = $this->createClient(['test_case' => 'SecurityHelper', 'root_config' => 'config.yml', 'debug' > true]); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php index f376847214913..dea034e5247b2 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php @@ -11,14 +11,13 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Security\Http\Firewall\SwitchUserListener; class SwitchUserTest extends AbstractWebTestCase { - /** - * @dataProvider getTestParameters - */ + #[DataProvider('getTestParameters')] public function testSwitchUser($originalUser, $targetUser, $expectedUser, $expectedStatus) { $client = $this->createAuthenticatedClient($originalUser, ['root_config' => 'switchuser.yml']); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallMapTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallMapTest.php index 81c85ad76c204..9f4bb72929a77 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallMapTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallMapTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Security; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\Security\FirewallConfig; use Symfony\Bundle\SecurityBundle\Security\FirewallContext; @@ -57,7 +58,7 @@ public function testGetListenersWithInvalidParameter() $this->assertFalse($request->attributes->has('_stateless')); } - /** @dataProvider providesStatefulStatelessRequests */ + #[DataProvider('providesStatefulStatelessRequests')] public function testGetListeners(Request $request, bool $expectedState) { $firewallContext = $this->createMock(FirewallContext::class); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/SecurityTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/SecurityTest.php index 9a126ae328e08..5553f81d55087 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/SecurityTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/SecurityTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Symfony\Bundle\SecurityBundle\Security; @@ -55,9 +56,7 @@ public function testGetToken() $this->assertSame($token, $security->getToken()); } - /** - * @dataProvider getUserTests - */ + #[DataProvider('getUserTests')] public function testGetUser($userInToken, $expectedUser) { $token = $this->createMock(TokenInterface::class); @@ -99,9 +98,7 @@ public function testIsGranted() $this->assertTrue($security->isGranted('SOME_ATTRIBUTE', 'SOME_SUBJECT')); } - /** - * @dataProvider getFirewallConfigTests - */ + #[DataProvider('getFirewallConfigTests')] public function testGetFirewallConfig(Request $request, ?FirewallConfig $expectedFirewallConfig) { $firewallMap = $this->createMock(FirewallMap::class); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index fc7303890c699..197b27df248be 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -63,9 +63,7 @@ public function testLoadEmptyConfiguration() } } - /** - * @dataProvider getFormatsAndBuildDir - */ + #[DataProvider('getFormatsAndBuildDir')] public function testLoadFullConfiguration(string $format, ?string $buildDir) { $container = $this->createContainer($buildDir); @@ -108,9 +106,7 @@ public function testLoadFullConfiguration(string $format, ?string $buildDir) $this->assertEquals(null !== $buildDir ? new Reference('twig.template_cache.chain') : '%kernel.cache_dir%/twig', $options['cache'], '->load() sets the cache option'); } - /** - * @dataProvider getFormatsAndBuildDir - */ + #[DataProvider('getFormatsAndBuildDir')] public function testLoadNoCacheConfiguration(string $format, ?string $buildDir) { $container = $this->createContainer($buildDir); @@ -125,9 +121,7 @@ public function testLoadNoCacheConfiguration(string $format, ?string $buildDir) $this->assertFalse($options['cache'], '->load() sets cache option to false'); } - /** - * @dataProvider getFormatsAndBuildDir - */ + #[DataProvider('getFormatsAndBuildDir')] public function testLoadPathCacheConfiguration(string $format, ?string $buildDir) { $container = $this->createContainer($buildDir); @@ -142,9 +136,7 @@ public function testLoadPathCacheConfiguration(string $format, ?string $buildDir $this->assertSame('random-path', $options['cache'], '->load() sets cache option to string path'); } - /** - * @dataProvider getFormatsAndBuildDir - */ + #[DataProvider('getFormatsAndBuildDir')] public function testLoadProdCacheConfiguration(string $format, ?string $buildDir) { $container = $this->createContainer($buildDir); @@ -176,9 +168,7 @@ public function testLoadCustomBaseTemplateClassConfiguration(string $format) $this->assertEquals('stdClass', $options['base_template_class'], '->load() sets the base_template_class option'); } - /** - * @dataProvider getFormats - */ + #[DataProvider('getFormats')] public function testLoadCustomTemplateEscapingGuesserConfiguration(string $format) { $container = $this->createContainer(); @@ -190,9 +180,7 @@ public function testLoadCustomTemplateEscapingGuesserConfiguration(string $forma $this->assertEquals([new Reference('my_project.some_bundle.template_escaping_guesser'), 'guess'], $options['autoescape']); } - /** - * @dataProvider getFormats - */ + #[DataProvider('getFormats')] public function testLoadDefaultTemplateEscapingGuesserConfiguration(string $format) { $container = $this->createContainer(); @@ -204,9 +192,7 @@ public function testLoadDefaultTemplateEscapingGuesserConfiguration(string $form $this->assertEquals('name', $options['autoescape']); } - /** - * @dataProvider getFormats - */ + #[DataProvider('getFormats')] public function testLoadCustomDateFormats(string $fileFormat) { $container = $this->createContainer(); @@ -253,9 +239,7 @@ public function testGlobalsWithDifferentTypesAndValues() } } - /** - * @dataProvider getFormats - */ + #[DataProvider('getFormats')] public function testTwigLoaderPaths(string $format) { $container = $this->createContainer(); @@ -306,9 +290,7 @@ public static function getFormatsAndBuildDir(): array ]; } - /** - * @dataProvider stopwatchExtensionAvailabilityProvider - */ + #[DataProvider('stopwatchExtensionAvailabilityProvider')] public function testStopwatchExtensionAvailability(bool $debug, bool $stopwatchEnabled, bool $expected) { $container = $this->createContainer(); @@ -361,9 +343,7 @@ public function testRuntimeLoader() $this->assertEquals('foo', $args['FooClass']->getValues()[0]); } - /** - * @dataProvider getFormats - */ + #[DataProvider('getFormats')] public function testCustomHtmlToTextConverterService(string $format) { if (!class_exists(Mailer::class)) { diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/AttributeExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/AttributeExtensionTest.php index 32db815b16a37..33ec37934a517 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Functional/AttributeExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Functional/AttributeExtensionTest.php @@ -32,7 +32,6 @@ class AttributeExtensionTest extends TestCase { - /** @beforeClass */ #[BeforeClass] public static function assertTwigVersion(): void { @@ -90,11 +89,6 @@ public function registerContainerConfiguration(LoaderInterface $loader): void $kernel->boot(); } - /** - * @before - * - * @after - */ #[Before, After] protected function deleteTempDir() { diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index 0e0a1e0aae79c..aa04f60993b28 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\Controller; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -122,9 +123,7 @@ public function testToolbarActionWithProfilerDisabled() $controller->toolbarAction(Request::create('/_wdt/foo-token'), null); } - /** - * @dataProvider getEmptyTokenCases - */ + #[DataProvider('getEmptyTokenCases')] public function testToolbarActionWithEmptyToken($token) { $urlGenerator = $this->createMock(UrlGeneratorInterface::class); @@ -173,9 +172,7 @@ public static function getEmptyTokenCases() ]; } - /** - * @dataProvider getOpenFileCases - */ + #[DataProvider('getOpenFileCases')] public function testOpeningDisallowedPaths($path, $isAllowed) { $urlGenerator = $this->createMock(UrlGeneratorInterface::class); @@ -206,9 +203,7 @@ public static function getOpenFileCases() ]; } - /** - * @dataProvider provideCspVariants - */ + #[DataProvider('provideCspVariants')] public function testReturns404onTokenNotFound($withCsp) { $twig = $this->createMock(Environment::class); @@ -256,9 +251,7 @@ public function testSearchBarActionDefaultPage() } } - /** - * @dataProvider provideCspVariants - */ + #[DataProvider('provideCspVariants')] public function testSearchResultsAction($withCsp) { $twig = $this->createMock(Environment::class); @@ -433,9 +426,7 @@ public static function provideCspVariants(): array ]; } - /** - * @dataProvider defaultPanelProvider - */ + #[DataProvider('defaultPanelProvider')] public function testDefaultPanel(string $expectedPanel, Profile $profile) { $this->assertDefaultPanel($expectedPanel, $profile); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php index bce62829467b9..be40fde08920a 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\Csp; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler; use Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator; @@ -19,9 +20,7 @@ class ContentSecurityPolicyHandlerTest extends TestCase { - /** - * @dataProvider provideRequestAndResponses - */ + #[DataProvider('provideRequestAndResponses')] public function testGetNonces($nonce, $expectedNonce, Request $request, Response $response) { $cspHandler = new ContentSecurityPolicyHandler($this->mockNonceGenerator($nonce)); @@ -29,9 +28,7 @@ public function testGetNonces($nonce, $expectedNonce, Request $request, Response $this->assertSame($expectedNonce, $cspHandler->getNonces($request, $response)); } - /** - * @dataProvider provideRequestAndResponsesForOnKernelResponse - */ + #[DataProvider('provideRequestAndResponsesForOnKernelResponse')] public function testOnKernelResponse($nonce, $expectedNonce, Request $request, Response $response, array $expectedCsp) { $cspHandler = new ContentSecurityPolicyHandler($this->mockNonceGenerator($nonce)); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php index 6a9fc99f10281..11b19b35bcf51 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -11,15 +11,14 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\DependencyInjection; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\WebProfilerBundle\DependencyInjection\Configuration; use Symfony\Component\Config\Definition\Processor; class ConfigurationTest extends TestCase { - /** - * @dataProvider getDebugModes - */ + #[DataProvider('getDebugModes')] public function testConfigTree(array $options, array $expectedResult) { $processor = new Processor(); @@ -79,9 +78,7 @@ public static function getDebugModes() ]; } - /** - * @dataProvider getInterceptRedirectsConfiguration - */ + #[DataProvider('getInterceptRedirectsConfiguration')] public function testConfigTreeUsingInterceptRedirects(bool $interceptRedirects, array $expectedResult) { $processor = new Processor(); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php index 490bc91e6661d..72d4780e301bd 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\DependencyInjection; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use Symfony\Bundle\WebProfilerBundle\DependencyInjection\WebProfilerExtension; use Symfony\Bundle\WebProfilerBundle\Tests\TestCase; @@ -88,9 +89,7 @@ protected function tearDown(): void $this->container = null; } - /** - * @dataProvider getDebugModes - */ + #[DataProvider('getDebugModes')] public function testDefaultConfig($debug) { $this->container->setParameter('kernel.debug', $debug); @@ -112,9 +111,7 @@ public static function getDebugModes() ]; } - /** - * @dataProvider getToolbarConfig - */ + #[DataProvider('getToolbarConfig')] public function testToolbarConfig(bool $toolbarEnabled, bool $listenerInjected, bool $listenerEnabled) { $extension = new WebProfilerExtension(); @@ -146,9 +143,7 @@ public static function getToolbarConfig() ]; } - /** - * @dataProvider getInterceptRedirectsToolbarConfig - */ + #[DataProvider('getInterceptRedirectsToolbarConfig')] public function testToolbarConfigUsingInterceptRedirects( bool $toolbarEnabled, bool $interceptRedirects, diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php index 981c85beed41f..420e8393d376c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\EventListener; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler; use Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener; @@ -25,9 +27,7 @@ class WebDebugToolbarListenerTest extends TestCase { - /** - * @dataProvider getInjectToolbarTests - */ + #[DataProvider('getInjectToolbarTests')] public function testInjectToolbar($content, $expected) { $listener = new WebDebugToolbarListener($this->getTwigMock()); @@ -57,9 +57,7 @@ public static function getInjectToolbarTests() ]; } - /** - * @dataProvider provideRedirects - */ + #[DataProvider('provideRedirects')] public function testHtmlRedirectionIsIntercepted($statusCode) { $response = new Response('Some content', $statusCode); @@ -101,9 +99,7 @@ public function testToolbarIsInjected() $this->assertEquals("\nWDT\n", $response->getContent()); } - /** - * @depends testToolbarIsInjected - */ + #[Depends('testToolbarIsInjected')] public function testToolbarIsNotInjectedOnNonHtmlContentType() { $response = new Response(''); @@ -117,9 +113,7 @@ public function testToolbarIsNotInjectedOnNonHtmlContentType() $this->assertEquals('', $response->getContent()); } - /** - * @depends testToolbarIsInjected - */ + #[Depends('testToolbarIsInjected')] public function testToolbarIsNotInjectedOnContentDispositionAttachment() { $response = new Response(''); @@ -133,11 +127,8 @@ public function testToolbarIsNotInjectedOnContentDispositionAttachment() $this->assertEquals('', $response->getContent()); } - /** - * @depends testToolbarIsInjected - * - * @dataProvider provideRedirects - */ + #[DataProvider('provideRedirects')] + #[Depends('testToolbarIsInjected')] public function testToolbarIsNotInjectedOnRedirection($statusCode) { $response = new Response('', $statusCode); @@ -159,9 +150,7 @@ public static function provideRedirects(): array ]; } - /** - * @depends testToolbarIsInjected - */ + #[Depends('testToolbarIsInjected')] public function testToolbarIsNotInjectedWhenThereIsNoNoXDebugTokenResponseHeader() { $response = new Response(''); @@ -174,9 +163,7 @@ public function testToolbarIsNotInjectedWhenThereIsNoNoXDebugTokenResponseHeader $this->assertEquals('', $response->getContent()); } - /** - * @depends testToolbarIsInjected - */ + #[Depends('testToolbarIsInjected')] public function testToolbarIsNotInjectedWhenOnSubRequest() { $response = new Response(''); @@ -190,9 +177,7 @@ public function testToolbarIsNotInjectedWhenOnSubRequest() $this->assertEquals('', $response->getContent()); } - /** - * @depends testToolbarIsInjected - */ + #[Depends('testToolbarIsInjected')] public function testToolbarIsNotInjectedOnIncompleteHtmlResponses() { $response = new Response('
Some content
'); @@ -206,9 +191,7 @@ public function testToolbarIsNotInjectedOnIncompleteHtmlResponses() $this->assertEquals('
Some content
', $response->getContent()); } - /** - * @depends testToolbarIsInjected - */ + #[Depends('testToolbarIsInjected')] public function testToolbarIsNotInjectedOnXmlHttpRequests() { $response = new Response(''); @@ -225,9 +208,7 @@ public function testToolbarIsNotInjectedOnXmlHttpRequests() $this->assertEquals('', $response->getContent()); } - /** - * @depends testToolbarIsInjected - */ + #[Depends('testToolbarIsInjected')] public function testToolbarIsNotInjectedOnNonHtmlRequests() { $response = new Response(''); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/CodeExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/CodeExtensionTest.php index 314deea4b9550..3b55425475f26 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/CodeExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/CodeExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\Profiler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\WebProfilerBundle\Profiler\CodeExtension; use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter; @@ -129,9 +130,7 @@ public function testFormatFileIntegration() $this->assertEquals($expected, $this->render($template)); } - /** - * @dataProvider fileExcerptIntegrationProvider - */ + #[DataProvider('fileExcerptIntegrationProvider')] public function testFileExcerptIntegration(string $expected, array $data) { $template = <<<'TWIG' diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php index 4cddbe0f718fc..3256c273eb9eb 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php @@ -11,13 +11,12 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\Resources; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class IconTest extends TestCase { - /** - * @dataProvider provideIconFilePaths - */ + #[DataProvider('provideIconFilePaths')] public function testIconFileContents($iconFilePath) { $iconFilePath = realpath($iconFilePath); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Twig/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Twig/WebProfilerExtensionTest.php index f0cf4f36a196f..165efe4c67cf9 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Twig/WebProfilerExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Twig/WebProfilerExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\Twig; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bundle\WebProfilerBundle\Twig\WebProfilerExtension; use Symfony\Component\VarDumper\Cloner\VarCloner; @@ -19,9 +20,7 @@ class WebProfilerExtensionTest extends TestCase { - /** - * @dataProvider provideMessages - */ + #[DataProvider('provideMessages')] public function testDumpHeaderIsDisplayed(string $message, array $context, bool $dump1HasHeader, bool $dump2HasHeader) { $twigEnvironment = new Environment(new ArrayLoader()); diff --git a/src/Symfony/Component/Asset/Tests/PackageTest.php b/src/Symfony/Component/Asset/Tests/PackageTest.php index 45b0982182082..b672c6b0073ab 100644 --- a/src/Symfony/Component/Asset/Tests/PackageTest.php +++ b/src/Symfony/Component/Asset/Tests/PackageTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Asset\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\Package; use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy; @@ -18,9 +19,7 @@ class PackageTest extends TestCase { - /** - * @dataProvider getConfigs - */ + #[DataProvider('getConfigs')] public function testGetUrl($version, $format, $path, $expected) { $package = new Package($version ? new StaticVersionStrategy($version, $format) : new EmptyVersionStrategy()); diff --git a/src/Symfony/Component/Asset/Tests/PathPackageTest.php b/src/Symfony/Component/Asset/Tests/PathPackageTest.php index 0784ac6fa89c0..274cbc826a0ab 100644 --- a/src/Symfony/Component/Asset/Tests/PathPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/PathPackageTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Asset\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\Context\ContextInterface; use Symfony\Component\Asset\PathPackage; @@ -19,9 +20,7 @@ class PathPackageTest extends TestCase { - /** - * @dataProvider getConfigs - */ + #[DataProvider('getConfigs')] public function testGetUrl($basePath, $format, $path, $expected) { $package = new PathPackage($basePath, new StaticVersionStrategy('v1', $format)); @@ -50,9 +49,7 @@ public static function getConfigs() ]; } - /** - * @dataProvider getContextConfigs - */ + #[DataProvider('getContextConfigs')] public function testGetUrlWithContext($basePathRequest, $basePath, $format, $path, $expected) { $package = new PathPackage($basePath, new StaticVersionStrategy('v1', $format), $this->getContext($basePathRequest)); diff --git a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php index db17fc67a505c..2d9a679694efb 100644 --- a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Asset\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\Context\ContextInterface; use Symfony\Component\Asset\Exception\InvalidArgumentException; @@ -22,9 +23,7 @@ class UrlPackageTest extends TestCase { - /** - * @dataProvider getConfigs - */ + #[DataProvider('getConfigs')] public function testGetUrl($baseUrls, string $format, string $path, string $expected) { $package = new UrlPackage($baseUrls, new StaticVersionStrategy('v1', $format)); @@ -62,9 +61,7 @@ public static function getConfigs(): array ]; } - /** - * @dataProvider getContextConfigs - */ + #[DataProvider('getContextConfigs')] public function testGetUrlWithContext(bool $secure, $baseUrls, string $format, string $path, string $expected) { $package = new UrlPackage($baseUrls, new StaticVersionStrategy('v1', $format), $this->getContext($secure)); @@ -107,9 +104,7 @@ public function testNoBaseUrls() new UrlPackage([], new EmptyVersionStrategy()); } - /** - * @dataProvider getWrongBaseUrlConfig - */ + #[DataProvider('getWrongBaseUrlConfig')] public function testWrongBaseUrl(string $baseUrls) { $this->expectException(InvalidArgumentException::class); diff --git a/src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php b/src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php index ce4f2854a313c..143e1b99ecc59 100644 --- a/src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php +++ b/src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Asset\Tests\VersionStrategy; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\Exception\AssetNotFoundException; use Symfony\Component\Asset\Exception\RuntimeException; @@ -20,33 +21,25 @@ class JsonManifestVersionStrategyTest extends TestCase { - /** - * @dataProvider provideValidStrategies - */ + #[DataProvider('provideValidStrategies')] public function testGetVersion(JsonManifestVersionStrategy $strategy) { $this->assertSame('main.123abc.js', $strategy->getVersion('main.js')); } - /** - * @dataProvider provideValidStrategies - */ + #[DataProvider('provideValidStrategies')] public function testApplyVersion(JsonManifestVersionStrategy $strategy) { $this->assertSame('css/styles.555def.css', $strategy->applyVersion('css/styles.css')); } - /** - * @dataProvider provideValidStrategies - */ + #[DataProvider('provideValidStrategies')] public function testApplyVersionWhenKeyDoesNotExistInManifest(JsonManifestVersionStrategy $strategy) { $this->assertSame('css/other.css', $strategy->applyVersion('css/other.css')); } - /** - * @dataProvider provideStrictStrategies - */ + #[DataProvider('provideStrictStrategies')] public function testStrictExceptionWhenKeyDoesNotExistInManifest(JsonManifestVersionStrategy $strategy, $path, $message) { $this->expectException(AssetNotFoundException::class); @@ -55,18 +48,14 @@ public function testStrictExceptionWhenKeyDoesNotExistInManifest(JsonManifestVer $strategy->getVersion($path); } - /** - * @dataProvider provideMissingStrategies - */ + #[DataProvider('provideMissingStrategies')] public function testMissingManifestFileThrowsException(JsonManifestVersionStrategy $strategy) { $this->expectException(RuntimeException::class); $strategy->getVersion('main.js'); } - /** - * @dataProvider provideInvalidStrategies - */ + #[DataProvider('provideInvalidStrategies')] public function testManifestFileWithBadJSONThrowsException(JsonManifestVersionStrategy $strategy) { $this->expectException(RuntimeException::class); diff --git a/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php b/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php index c2878875f323f..4a5dbf8c7a19f 100644 --- a/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php +++ b/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Asset\Tests\VersionStrategy; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy; @@ -24,9 +25,7 @@ public function testGetVersion() $this->assertSame($version, $staticVersionStrategy->getVersion($path)); } - /** - * @dataProvider getConfigs - */ + #[DataProvider('getConfigs')] public function testApplyVersion($path, $version, $format) { $staticVersionStrategy = new StaticVersionStrategy($version, $format); diff --git a/src/Symfony/Component/AssetMapper/Tests/Command/ImportMapRequireCommandTest.php b/src/Symfony/Component/AssetMapper/Tests/Command/ImportMapRequireCommandTest.php index fb410bafab2a4..008a32f474d7e 100644 --- a/src/Symfony/Component/AssetMapper/Tests/Command/ImportMapRequireCommandTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/Command/ImportMapRequireCommandTest.php @@ -32,9 +32,7 @@ protected static function getKernelClass(): string return ImportMapTestAppKernel::class; } - /** - * @dataProvider getRequirePackageTests - */ + #[DataProvider('getRequirePackageTests')] public function testDryRunOptionToShowInformationBeforeApplyInstallation(int $verbosity, array $packageEntries, array $packagesToInstall, string $expected, ?string $path = null) { $importMapManager = $this->createMock(ImportMapManager::class); diff --git a/src/Symfony/Component/AssetMapper/Tests/Compiler/CssAssetUrlCompilerTest.php b/src/Symfony/Component/AssetMapper/Tests/Compiler/CssAssetUrlCompilerTest.php index 067168b059a71..9d9b412ae7d15 100644 --- a/src/Symfony/Component/AssetMapper/Tests/Compiler/CssAssetUrlCompilerTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/Compiler/CssAssetUrlCompilerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests\Compiler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Symfony\Component\AssetMapper\AssetMapperInterface; @@ -20,9 +21,7 @@ class CssAssetUrlCompilerTest extends TestCase { - /** - * @dataProvider provideCompileTests - */ + #[DataProvider('provideCompileTests')] public function testCompile(string $input, string $expectedOutput, array $expectedDependencies) { $assetMapper = $this->createMock(AssetMapperInterface::class); @@ -182,9 +181,7 @@ public function testCompileFindsRelativeFilesViaSourcePath() $this->assertSame($expectedOutput, $compiler->compile($input, $asset, $assetMapper)); } - /** - * @dataProvider provideStrictModeTests - */ + #[DataProvider('provideStrictModeTests')] public function testStrictMode(string $sourceLogicalName, string $input, ?string $expectedExceptionMessage) { if (null !== $expectedExceptionMessage) { diff --git a/src/Symfony/Component/AssetMapper/Tests/Compiler/JavaScriptImportPathCompilerTest.php b/src/Symfony/Component/AssetMapper/Tests/Compiler/JavaScriptImportPathCompilerTest.php index 084b5eefaa216..ff3c9b3adf2ef 100644 --- a/src/Symfony/Component/AssetMapper/Tests/Compiler/JavaScriptImportPathCompilerTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/Compiler/JavaScriptImportPathCompilerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests\Compiler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Symfony\Component\AssetMapper\AssetMapperInterface; @@ -25,9 +26,7 @@ class JavaScriptImportPathCompilerTest extends TestCase { - /** - * @dataProvider provideCompileTests - */ + #[DataProvider('provideCompileTests')] public function testCompileFindsCorrectImports(string $input, array $expectedJavaScriptImports) { $asset = new MappedAsset('app.js', '/project/assets/app.js', publicPathWithoutDigest: '/assets/app.js'); @@ -456,9 +455,7 @@ public function testCompileFindsRelativePathsWithWindowsPathsViaSourcePath() $this->assertSame('root_asset.js', $inputAsset->getJavaScriptImports()[2]->assetLogicalPath); } - /** - * @dataProvider providePathsCanUpdateTests - */ + #[DataProvider('providePathsCanUpdateTests')] public function testImportPathsCanUpdateForDifferentPublicPath(string $input, string $inputAssetPublicPath, string $importedPublicPath, string $expectedOutput) { $asset = new MappedAsset('app.js', '/path/to/assets/app.js', publicPathWithoutDigest: $inputAssetPublicPath); @@ -593,9 +590,7 @@ public function testCompileIgnoresSelfReferencingBareImportAssets() $this->assertCount(0, $bootstrapAsset->getJavaScriptImports()); } - /** - * @dataProvider provideMissingImportModeTests - */ + #[DataProvider('provideMissingImportModeTests')] public function testMissingImportMode(string $sourceLogicalName, string $input, ?string $expectedExceptionMessage) { if (null !== $expectedExceptionMessage) { diff --git a/src/Symfony/Component/AssetMapper/Tests/Compiler/Parser/JavascriptSequenceParserTest.php b/src/Symfony/Component/AssetMapper/Tests/Compiler/Parser/JavascriptSequenceParserTest.php index 794b7bbf61d94..9bc3d9fcca013 100644 --- a/src/Symfony/Component/AssetMapper/Tests/Compiler/Parser/JavascriptSequenceParserTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/Compiler/Parser/JavascriptSequenceParserTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests\Compiler\Parser; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\AssetMapper\Compiler\Parser\JavascriptSequenceParser; @@ -53,9 +54,7 @@ public function testParseToTheEnd() $this->assertTrue($parser->isExecutable()); } - /** - * @dataProvider provideSequenceCases - */ + #[DataProvider('provideSequenceCases')] public function testParseSequence(string $content, int $position, bool $isExcecutable) { $parser = new JavascriptSequenceParser($content); @@ -103,9 +102,7 @@ public static function provideSequenceCases(): iterable ]; } - /** - * @dataProvider provideCommentCases - */ + #[DataProvider('provideCommentCases')] public function testIdentifyComment(string $content, int $position, bool $isComment) { $parser = new JavascriptSequenceParser($content); @@ -169,9 +166,7 @@ public static function provideCommentCases(): iterable ]; } - /** - * @dataProvider provideStringCases - */ + #[DataProvider('provideStringCases')] public function testIdentifyStrings(string $content, int $position, bool $isString) { $parser = new JavascriptSequenceParser($content); diff --git a/src/Symfony/Component/AssetMapper/Tests/Compiler/SourceMappingUrlsCompilerTest.php b/src/Symfony/Component/AssetMapper/Tests/Compiler/SourceMappingUrlsCompilerTest.php index 975f930166b84..9fe25942a25ee 100644 --- a/src/Symfony/Component/AssetMapper/Tests/Compiler/SourceMappingUrlsCompilerTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/Compiler/SourceMappingUrlsCompilerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests\Compiler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\AssetMapper\AssetMapperInterface; use Symfony\Component\AssetMapper\Compiler\SourceMappingUrlsCompiler; @@ -18,9 +19,7 @@ class SourceMappingUrlsCompilerTest extends TestCase { - /** - * @dataProvider provideCompileTests - */ + #[DataProvider('provideCompileTests')] public function testCompile(string $sourceLogicalName, string $input, string $expectedOutput, $expectedDependencies) { $assetMapper = $this->createMock(AssetMapperInterface::class); diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapAuditorTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapAuditorTest.php index d98900a61643e..008371b6c7f1f 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapAuditorTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapAuditorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests\ImportMap; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\AssetMapper\Exception\RuntimeException; use Symfony\Component\AssetMapper\ImportMap\ImportMapAuditor; @@ -89,9 +90,7 @@ public function testAudit() ], $audit); } - /** - * @dataProvider provideAuditWithVersionRange - */ + #[DataProvider('provideAuditWithVersionRange')] public function testAuditWithVersionRange(bool $expectMatch, string $version, ?string $versionRange) { $this->httpClient->setResponseFactory(new JsonMockResponse([ diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapConfigReaderTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapConfigReaderTest.php index 4db3a8dc9b24b..0793b7362bb47 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapConfigReaderTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapConfigReaderTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests\ImportMap; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\TestCase; @@ -108,9 +109,7 @@ public function testGetEntriesAndWriteEntries() $this->assertSame($originalImportMapData, $newImportMapData); } - /** - * @dataProvider getPathToFilesystemPathTests - */ + #[DataProvider('getPathToFilesystemPathTests')] public function testConvertPathToFilesystemPath(string $path, string $expectedPath) { $configReader = new ImportMapConfigReader(realpath(__DIR__.'/../Fixtures/importmap.php'), $this->createMock(RemotePackageStorage::class)); @@ -132,9 +131,7 @@ public static function getPathToFilesystemPathTests() ]; } - /** - * @dataProvider getFilesystemPathToPathTests - */ + #[DataProvider('getFilesystemPathToPathTests')] public function testConvertFilesystemPathToPath(string $path, ?string $expectedPath) { $configReader = new ImportMapConfigReader(__DIR__.'/../Fixtures/importmap.php', $this->createMock(RemotePackageStorage::class)); diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapEntryTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapEntryTest.php index 808fd1adcad76..2cfe4c709705a 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapEntryTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapEntryTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests\ImportMap; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\AssetMapper\ImportMap\ImportMapEntry; use Symfony\Component\AssetMapper\ImportMap\ImportMapType; @@ -39,9 +40,7 @@ public function testCreateRemote() $this->assertSame('foo/bar', $entry->packageModuleSpecifier); } - /** - * @dataProvider getSplitPackageNameTests - */ + #[DataProvider('getSplitPackageNameTests')] public function testSplitPackageNameAndFilePath(string $packageModuleSpecifier, string $expectedPackage, string $expectedPath) { [$actualPackage, $actualPath] = ImportMapEntry::splitPackageNameAndFilePath($packageModuleSpecifier); diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapGeneratorTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapGeneratorTest.php index bdc8bc36c1ed7..e24708fc3fc32 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapGeneratorTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapGeneratorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests\ImportMap; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\AssetMapper\AssetMapperInterface; @@ -254,9 +255,7 @@ public function testGetImportMapData() ], array_keys($actualImportMapData)); } - /** - * @dataProvider getRawImportMapDataTests - */ + #[DataProvider('getRawImportMapDataTests')] public function testGetRawImportMapData(array $importMapEntries, array $mappedAssets, array $expectedData) { $manager = $this->createImportMapGenerator(); @@ -595,9 +594,7 @@ public function testGetRawImportDataUsesCacheFile() $this->assertEquals($importmapData, $manager->getRawImportMapData()); } - /** - * @dataProvider getEagerEntrypointImportsTests - */ + #[DataProvider('getEagerEntrypointImportsTests')] public function testFindEagerEntrypointImports(MappedAsset $entryAsset, array $expected, array $mappedAssets = []) { $manager = $this->createImportMapGenerator(); diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapManagerTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapManagerTest.php index e6084fc7c1e87..ec94f716db0a1 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapManagerTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapManagerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests\ImportMap; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\AssetMapper\AssetMapperInterface; @@ -49,9 +50,7 @@ protected function tearDown(): void $this->filesystem->remove(self::$writableRoot); } - /** - * @dataProvider getRequirePackageTests - */ + #[DataProvider('getRequirePackageTests')] public function testRequire(array $packages, int $expectedProviderPackageArgumentCount, array $resolvedPackages, array $expectedImportMap) { $manager = $this->createImportMapManager(); @@ -248,7 +247,7 @@ public function testUpdateAll() ->method('resolvePackages') ->with($this->callback(function ($packages) { $this->assertInstanceOf(PackageRequireOptions::class, $packages[0]); - /** @var PackageRequireOptions[] $packages */ + /* @var PackageRequireOptions[] $packages */ $this->assertCount(2, $packages); $this->assertSame('lodash', $packages[0]->packageModuleSpecifier); @@ -314,9 +313,7 @@ public function testUpdateWithSpecificPackages() $manager->update(['cowsay']); } - /** - * @dataProvider getPackageNameTests - */ + #[DataProvider('getPackageNameTests')] public function testParsePackageName(string $packageName, array $expectedReturn) { $parsed = ImportMapManager::parsePackageName($packageName); diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapOutdatedCommandTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapOutdatedCommandTest.php index cc53f7beeebdd..4ae39676f80c3 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapOutdatedCommandTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapOutdatedCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests\ImportMap; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\AssetMapper\Command\ImportMapOutdatedCommand; use Symfony\Component\AssetMapper\ImportMap\ImportMapUpdateChecker; @@ -18,9 +19,7 @@ class ImportMapOutdatedCommandTest extends TestCase { - /** - * @dataProvider provideNoOutdatedPackageCases - */ + #[DataProvider('provideNoOutdatedPackageCases')] public function testCommandWhenNoOutdatedPackages(string $display, ?string $format = null) { $updateChecker = $this->createMock(ImportMapUpdateChecker::class); diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapUpdateCheckerTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapUpdateCheckerTest.php index 689820d64f32e..6c6a07d6cbe3e 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapUpdateCheckerTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapUpdateCheckerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests\ImportMap; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\AssetMapper\ImportMap\ImportMapConfigReader; use Symfony\Component\AssetMapper\ImportMap\ImportMapEntries; @@ -110,11 +111,10 @@ public function testGetAvailableUpdates() } /** - * @dataProvider provideImportMapEntry - * * @param ImportMapEntry[] $entries * @param PackageUpdateInfo[] $expectedUpdateInfo */ + #[DataProvider('provideImportMapEntry')] public function testGetAvailableUpdatesForSinglePackage(array $entries, array $expectedUpdateInfo, ?\Exception $expectedException) { $this->importMapConfigReader->method('getEntries')->willReturn(new ImportMapEntries($entries)); diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php index 3b54bd3a5b5b6..ab02e5c7da05c 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests\ImportMap; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\AssetMapper\ImportMap\ImportMapConfigReader; use Symfony\Component\AssetMapper\ImportMap\ImportMapEntries; @@ -24,9 +25,7 @@ class ImportMapVersionCheckerTest extends TestCase { - /** - * @dataProvider getCheckVersionsTests - */ + #[DataProvider('getCheckVersionsTests')] public function testCheckVersions(array $importMapEntries, array $dependencies, array $expectedRequests, array $expectedProblems) { $configReader = $this->createMock(ImportMapConfigReader::class); @@ -283,9 +282,7 @@ public static function getCheckVersionsTests() ]; } - /** - * @dataProvider getNpmSpecificVersionConstraints - */ + #[DataProvider('getNpmSpecificVersionConstraints')] public function testNpmSpecificConstraints(string $npmConstraint, ?string $expectedComposerConstraint) { $this->assertSame($expectedComposerConstraint, ImportMapVersionChecker::convertNpmConstraint($npmConstraint)); diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/PackageUpdateInfoTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/PackageUpdateInfoTest.php index f86674c3ad723..3a0ab57337199 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/PackageUpdateInfoTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/PackageUpdateInfoTest.php @@ -11,14 +11,13 @@ namespace Symfony\Component\AssetMapper\Tests\ImportMap; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\AssetMapper\ImportMap\PackageUpdateInfo; class PackageUpdateInfoTest extends TestCase { - /** - * @dataProvider provideValidConstructorArguments - */ + #[DataProvider('provideValidConstructorArguments')] public function testConstructor($importName, $currentVersion, $latestVersion, $updateType) { $packageUpdateInfo = new PackageUpdateInfo( @@ -44,9 +43,7 @@ public static function provideValidConstructorArguments(): iterable ]; } - /** - * @dataProvider provideHasUpdateArguments - */ + #[DataProvider('provideHasUpdateArguments')] public function testHasUpdate($updateType, $expectUpdate) { $packageUpdateInfo = new PackageUpdateInfo( diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/RemotePackageStorageTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/RemotePackageStorageTest.php index 7c0f1541a85ed..c733e063af19c 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/RemotePackageStorageTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/RemotePackageStorageTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests\ImportMap; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\AssetMapper\ImportMap\ImportMapEntry; use Symfony\Component\AssetMapper\ImportMap\ImportMapType; @@ -113,9 +114,7 @@ public function testSaveExtraFile() $this->assertEquals('any content', $this->filesystem->readFile($targetPath)); } - /** - * @dataProvider getDownloadPathTests - */ + #[DataProvider('getDownloadPathTests')] public function testGetDownloadedPath(string $packageModuleSpecifier, ImportMapType $importMapType, string $expectedPath) { $storage = new RemotePackageStorage(self::$writableRoot.'/assets/vendor'); diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php index ffb153fe54366..39614a7b81662 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests\ImportMap\Resolver; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\AssetMapper\ImportMap\ImportMapEntry; use Symfony\Component\AssetMapper\ImportMap\ImportMapType; @@ -21,9 +22,7 @@ class JsDelivrEsmResolverTest extends TestCase { - /** - * @dataProvider provideResolvePackagesTests - */ + #[DataProvider('provideResolvePackagesTests')] public function testResolvePackages(array $packages, array $expectedRequests, array $expectedResolvedPackages) { $responses = []; @@ -265,9 +264,7 @@ public static function provideResolvePackagesTests(): iterable ]; } - /** - * @dataProvider provideDownloadPackagesTests - */ + #[DataProvider('provideDownloadPackagesTests')] public function testDownloadPackages(array $importMapEntries, array $expectedRequests, array $expectedReturn) { $responses = []; @@ -584,9 +581,7 @@ public function testDownloadCssRecursivelyDownloadsUrlCss() ]); } - /** - * @dataProvider provideImportRegex - */ + #[DataProvider('provideImportRegex')] public function testImportRegex(string $subject, array $expectedPackages) { preg_match_all(JsDelivrEsmResolver::IMPORT_REGEX, $subject, $matches); diff --git a/src/Symfony/Component/AssetMapper/Tests/MappedAssetTest.php b/src/Symfony/Component/AssetMapper/Tests/MappedAssetTest.php index e2bf6c1f22c54..6a98dfc92c2dd 100644 --- a/src/Symfony/Component/AssetMapper/Tests/MappedAssetTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/MappedAssetTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\AssetMapper\ImportMap\JavaScriptImport; use Symfony\Component\AssetMapper\MappedAsset; @@ -24,9 +25,7 @@ public function testGetLogicalPath() $this->assertSame('foo.css', $asset->logicalPath); } - /** - * @dataProvider getExtensionTests - */ + #[DataProvider('getExtensionTests')] public function testGetExtension(string $filename, string $expectedExtension) { $asset = new MappedAsset('anything', publicPathWithoutDigest: $filename); diff --git a/src/Symfony/Component/AssetMapper/Tests/MapperAwareAssetPackageTest.php b/src/Symfony/Component/AssetMapper/Tests/MapperAwareAssetPackageTest.php index adb656aab7f90..eeaedb84647f3 100644 --- a/src/Symfony/Component/AssetMapper/Tests/MapperAwareAssetPackageTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/MapperAwareAssetPackageTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\PackageInterface; use Symfony\Component\AssetMapper\AssetMapperInterface; @@ -31,9 +32,7 @@ public function testGetVersion() $this->assertSame('2.0', $assetMapperPackage->getVersion('foo')); } - /** - * @dataProvider getUrlTests - */ + #[DataProvider('getUrlTests')] public function testGetUrl(string $path, string $expectedPathSentToInner) { $inner = $this->createMock(PackageInterface::class); diff --git a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php index 096c07c701d3c..87290de7ff8de 100644 --- a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\BrowserKit\Tests; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use PHPUnit\Framework\TestCase; use Symfony\Component\BrowserKit\CookieJar; use Symfony\Component\BrowserKit\Exception\BadMethodCallException; @@ -650,9 +652,7 @@ public function testFollowRedirectDropPostMethod() } } - /** - * @dataProvider getTestsForMetaRefresh - */ + #[DataProvider('getTestsForMetaRefresh')] public function testFollowMetaRefresh(string $content, string $expectedEndingUrl, bool $followMetaRefresh = true) { $client = $this->getBrowser(); @@ -776,9 +776,7 @@ public function testRestart() $this->assertSame([], $client->getCookieJar()->all(), '->restart() clears the cookies'); } - /** - * @runInSeparateProcess - */ + #[RunInSeparateProcess] public function testInsulatedRequests() { $client = $this->getBrowser(); diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php index 2e456b82f2e9f..fc2a6f31ff96d 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\BrowserKit\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\BrowserKit\Cookie; use Symfony\Component\BrowserKit\CookieJar; @@ -114,9 +115,7 @@ public function testUpdateFromSetCookieWithMultipleCookies() $this->assertEquals($timestamp, $phpCookie->getExpiresTime()); } - /** - * @dataProvider provideAllValuesValues - */ + #[DataProvider('provideAllValuesValues')] public function testAllValues($uri, $values) { $cookieJar = new CookieJar(); diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php index 5d42ceb8a73da..a8a6f529732d3 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\BrowserKit\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\BrowserKit\Cookie; use Symfony\Component\BrowserKit\Exception\InvalidArgumentException; @@ -36,9 +37,7 @@ public function testToString() $this->assertEquals('foo=bar; expires=Thu, 01 Jan 1970 00:00:02 GMT; path=/; secure; httponly; samesite=lax', (string) $cookie); } - /** - * @dataProvider getTestsForToFromString - */ + #[DataProvider('getTestsForToFromString')] public function testToFromString($cookie, $url = null) { $this->assertEquals($cookie, (string) Cookie::fromString($cookie, $url)); @@ -65,9 +64,7 @@ public function testFromStringIgnoreSecureFlag() $this->assertFalse(Cookie::fromString('foo=bar; secure', 'http://example.com/')->isSecure()); } - /** - * @dataProvider getExpireCookieStrings - */ + #[DataProvider('getExpireCookieStrings')] public function testFromStringAcceptsSeveralExpiresDateFormats($cookie) { $this->assertEquals(1596185377, Cookie::fromString($cookie)->getExpiresTime()); diff --git a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php index 3a2547d89f488..322f1c5309932 100644 --- a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\BrowserKit\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\BrowserKit\CookieJar; use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\HttpBrowser; @@ -26,9 +27,7 @@ public function getBrowser(array $server = [], ?History $history = null, ?Cookie return new TestHttpClient($server, $history, $cookieJar); } - /** - * @dataProvider validContentTypes - */ + #[DataProvider('validContentTypes')] public function testRequestHeaders(array $requestArguments, array $expectedArguments) { $client = $this->createMock(HttpClientInterface::class); @@ -186,9 +185,7 @@ public function testMultiPartRequestWithAdditionalParametersOfTheSameName() ]); } - /** - * @dataProvider forwardSlashesRequestPathProvider - */ + #[DataProvider('forwardSlashesRequestPathProvider')] public function testMultipleForwardSlashesRequestPath(string $requestPath) { $client = $this->createMock(HttpClientInterface::class); diff --git a/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php b/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php index f68d0b565d87e..37b4b469f46c0 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\BrowserKit\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\BrowserKit\Exception\JsonException; use Symfony\Component\BrowserKit\Response; @@ -90,9 +91,7 @@ public function testToArray() ], $response->toArray(), '->toArray returns an array representation of json content'); } - /** - * @dataProvider provideInvalidJson - */ + #[DataProvider('provideInvalidJson')] public function testToArrayThrowsErrorOnInvalidJson(string $data) { $response = new Response($data); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php index c139cc9774eb2..699fb17235a04 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use Psr\Cache\CacheItemPoolInterface; use Relay\Cluster as RelayCluster; use Relay\Relay; @@ -43,9 +44,7 @@ public static function setUpBeforeClass(): void } } - /** - * @runInSeparateProcess - */ + #[RunInSeparateProcess] public function testClearWithPrefix() { $cache = $this->createCachePool(0, __FUNCTION__); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php index 7a2234454aa9e..0c75011538fce 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php @@ -11,14 +11,13 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Tests\Fixtures\TestEnum; use Symfony\Component\Clock\MockClock; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class ArrayAdapterTest extends AdapterTestCase { protected $skippedTests = [ diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php index 6f849a6bd08a6..f9a9ceadbd3d2 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\AdapterInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -25,9 +26,8 @@ /** * @author Kévin Dunglas - * - * @group time-sensitive */ +#[Group('time-sensitive')] class ChainAdapterTest extends AdapterTestCase { public function createCachePool(int $defaultLifetime = 0, ?string $testMethod = null): CacheItemPoolInterface diff --git a/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseCollectionAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseCollectionAdapterTest.php index 0e94de2b0d31b..232e095e6e3ee 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseCollectionAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseCollectionAdapterTest.php @@ -11,18 +11,18 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\CouchbaseCollectionAdapter; /** - * @requires extension couchbase <4.0.0 - * @requires extension couchbase >=3.0.5 - * - * @group integration - * * @author Antonio Jose Cerezo Aranda */ +#[RequiresPhpExtension('couchbase', '<4.0.0')] +#[RequiresPhpExtension('couchbase', '>=3.0.5')] +#[Group('integration')] class CouchbaseCollectionAdapterTest extends AdapterTestCase { protected $skippedTests = [ diff --git a/src/Symfony/Component/Cache/Tests/Adapter/DoctrineDbalAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/DoctrineDbalAdapterTest.php index db20b0f330dc3..2789528a3ff88 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/DoctrineDbalAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/DoctrineDbalAdapterTest.php @@ -19,15 +19,15 @@ use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory; use Doctrine\DBAL\Schema\Schema; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\MockObject\MockObject; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\DoctrineDbalAdapter; -/** - * @requires extension pdo_sqlite - * - * @group time-sensitive - */ +#[RequiresPhpExtension('pdo_sqlite')] +#[Group('time-sensitive')] class DoctrineDbalAdapterTest extends AdapterTestCase { protected static string $dbFile; @@ -120,9 +120,7 @@ public function testConfigureSchemaTableExists() $this->assertSame([], $table->getColumns(), 'The table was not overwritten'); } - /** - * @dataProvider provideDsnWithSQLite - */ + #[DataProvider('provideDsnWithSQLite')] public function testDsnWithSQLite(string $dsn, ?string $file = null) { try { @@ -146,11 +144,8 @@ public static function provideDsnWithSQLite() yield 'SQLite in memory' => ['sqlite://localhost/:memory:']; } - /** - * @requires extension pdo_pgsql - * - * @group integration - */ + #[RequiresPhpExtension('pdo_pgsql')] + #[Group('integration')] public function testDsnWithPostgreSQL() { if (!$host = getenv('POSTGRES_HOST')) { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/FilesystemAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/FilesystemAdapterTest.php index 848d164115038..71ae8d173bcd9 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/FilesystemAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/FilesystemAdapterTest.php @@ -11,13 +11,12 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Filesystem\Filesystem; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class FilesystemAdapterTest extends AdapterTestCase { public function createCachePool(int $defaultLifetime = 0): CacheItemPoolInterface diff --git a/src/Symfony/Component/Cache/Tests/Adapter/FilesystemTagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/FilesystemTagAwareAdapterTest.php index 393210e16e74e..4c0cd46ee451a 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/FilesystemTagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/FilesystemTagAwareAdapterTest.php @@ -11,12 +11,11 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\FilesystemTagAwareAdapter; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class FilesystemTagAwareAdapterTest extends FilesystemAdapterTest { use TagAwareTestTrait; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php index cf0e687bc9d73..7eff813dac009 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php @@ -11,14 +11,15 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\MemcachedAdapter; use Symfony\Component\Cache\Exception\CacheException; -/** - * @group integration - */ +#[Group('integration')] class MemcachedAdapterTest extends AdapterTestCase { protected $skippedTests = [ @@ -67,9 +68,7 @@ public function testOptions() $this->assertSame(\Memcached::DISTRIBUTION_MODULA, $client->getOption(\Memcached::OPT_DISTRIBUTION)); } - /** - * @dataProvider provideBadOptions - */ + #[DataProvider('provideBadOptions')] public function testBadOptions($name, $value) { $this->expectException(\Error::class); @@ -111,9 +110,7 @@ public function testOptionSerializer() new MemcachedAdapter(MemcachedAdapter::createConnection([], ['serializer' => 'json'])); } - /** - * @dataProvider provideServersSetting - */ + #[DataProvider('provideServersSetting')] public function testServersSetting(string $dsn, string $host, int $port) { $client1 = MemcachedAdapter::createConnection($dsn); @@ -168,9 +165,7 @@ public static function provideServersSetting(): iterable } } - /** - * @requires extension memcached - */ + #[RequiresPhpExtension('memcached')] public function testOptionsFromDsnWinOverAdditionallyPassedOptions() { $client = MemcachedAdapter::createConnection('memcached://localhost:11222?retry_timeout=10', [ @@ -180,9 +175,7 @@ public function testOptionsFromDsnWinOverAdditionallyPassedOptions() $this->assertSame(10, $client->getOption(\Memcached::OPT_RETRY_TIMEOUT)); } - /** - * @requires extension memcached - */ + #[RequiresPhpExtension('memcached')] public function testOptionsFromDsnAndAdditionallyPassedOptionsAreMerged() { $client = MemcachedAdapter::createConnection('memcached://localhost:11222?socket_recv_size=1&socket_send_size=2', [ diff --git a/src/Symfony/Component/Cache/Tests/Adapter/NamespacedProxyAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/NamespacedProxyAdapterTest.php index 4e6ebede0a596..ef189bdd2511f 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/NamespacedProxyAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/NamespacedProxyAdapterTest.php @@ -11,14 +11,13 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\ProxyAdapter; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class NamespacedProxyAdapterTest extends ProxyAdapterTest { public function createCachePool(int $defaultLifetime = 0, ?string $testMethod = null): CacheItemPoolInterface diff --git a/src/Symfony/Component/Cache/Tests/Adapter/NullAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/NullAdapterTest.php index a3b73bd959aad..2261160f61167 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/NullAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/NullAdapterTest.php @@ -11,13 +11,12 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Psr\Cache\CacheItemInterface; use Symfony\Component\Cache\Adapter\NullAdapter; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class NullAdapterTest extends TestCase { public function createCachePool() diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php index 49f3da83fe234..c2ed0d6f6ae65 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php @@ -11,15 +11,15 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\PdoAdapter; -/** - * @requires extension pdo_sqlite - * - * @group time-sensitive - */ +#[RequiresPhpExtension('pdo_sqlite')] +#[Group('time-sensitive')] class PdoAdapterTest extends AdapterTestCase { protected static string $dbFile; @@ -76,9 +76,7 @@ public function testCleanupExpiredItems() $this->assertSame(0, $getCacheItemCount(), 'PDOAdapter must clean up expired items'); } - /** - * @dataProvider provideDsnSQLite - */ + #[DataProvider('provideDsnSQLite')] public function testDsnWithSQLite(string $dsn, ?string $file = null) { try { @@ -101,11 +99,8 @@ public static function provideDsnSQLite() yield 'SQLite in memory' => ['sqlite::memory:']; } - /** - * @requires extension pdo_pgsql - * - * @group integration - */ + #[RequiresPhpExtension('pdo_pgsql')] + #[Group('integration')] public function testDsnWithPostgreSQL() { if (!$host = getenv('POSTGRES_HOST')) { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php index 0c856e6f5770c..2b995d15d9c7e 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\FilesystemAdapter; @@ -18,9 +19,7 @@ use Symfony\Component\Cache\Adapter\PhpArrayAdapter; use Symfony\Component\Filesystem\Filesystem; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class PhpArrayAdapterTest extends AdapterTestCase { protected $skippedTests = [ diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php index 0f92aee451506..a23e7cf74db5a 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php @@ -11,14 +11,13 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\PhpArrayAdapter; use Symfony\Component\Filesystem\Filesystem; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class PhpArrayAdapterWithFallbackTest extends AdapterTestCase { protected $skippedTests = [ diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterAppendOnlyTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterAppendOnlyTest.php index a38a6f9f5c61a..f0e79d6a2bd56 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterAppendOnlyTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterAppendOnlyTest.php @@ -11,12 +11,11 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\PhpFilesAdapter; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class PhpFilesAdapterAppendOnlyTest extends PhpFilesAdapterTest { protected $skippedTests = [ diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterTest.php index c645bbc3b1eca..c0c5097ca63d5 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterTest.php @@ -11,13 +11,12 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\PhpFilesAdapter; use Symfony\Component\Filesystem\Filesystem; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class PhpFilesAdapterTest extends AdapterTestCase { protected $skippedTests = [ diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterSentinelTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterSentinelTest.php index 6c86357101fd5..24a73acda52c5 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterSentinelTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterSentinelTest.php @@ -11,11 +11,10 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\Cache\Adapter\AbstractAdapter; -/** - * @group integration - */ +#[Group('integration')] class PredisAdapterSentinelTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php index 730bde7195fb1..e10c9936ca028 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php @@ -11,12 +11,11 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Predis\Connection\StreamConnection; use Symfony\Component\Cache\Adapter\RedisAdapter; -/** - * @group integration - */ +#[Group('integration')] class PredisAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisClusterAdapterTest.php index cfa106a06b15c..910a637695309 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisClusterAdapterTest.php @@ -11,9 +11,9 @@ namespace Symfony\Component\Cache\Tests\Adapter; -/** - * @group integration - */ +use PHPUnit\Framework\Attributes\Group; + +#[Group('integration')] class PredisClusterAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisClusterAdapterTest.php index fb9865883effd..0a8051ffc4edf 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisClusterAdapterTest.php @@ -11,11 +11,10 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\Cache\Adapter\RedisAdapter; -/** - * @group integration - */ +#[Group('integration')] class PredisRedisClusterAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php index cda92af8c7a6c..8cc10a5c19436 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php @@ -11,11 +11,10 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\Cache\Adapter\RedisAdapter; -/** - * @group integration - */ +#[Group('integration')] class PredisRedisReplicationAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php index b9877234a05af..ceaf1a45e2980 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php @@ -11,9 +11,9 @@ namespace Symfony\Component\Cache\Tests\Adapter; -/** - * @group integration - */ +use PHPUnit\Framework\Attributes\Group; + +#[Group('integration')] class PredisReplicationAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareAdapterTest.php index 0468e89449729..1506e407897bd 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareAdapterTest.php @@ -11,12 +11,11 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; -/** - * @group integration - */ +#[Group('integration')] class PredisTagAwareAdapterTest extends PredisAdapterTest { use TagAwareTestTrait; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareClusterAdapterTest.php index 3a118dc17147e..983fa60bd6ea7 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareClusterAdapterTest.php @@ -11,12 +11,11 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; -/** - * @group integration - */ +#[Group('integration')] class PredisTagAwareClusterAdapterTest extends PredisClusterAdapterTest { use TagAwareTestTrait; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterAndRedisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterAndRedisAdapterTest.php index 4bff8c33909d7..5e98872627d00 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterAndRedisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterAndRedisAdapterTest.php @@ -11,15 +11,14 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\ProxyAdapter; use Symfony\Component\Cache\Adapter\RedisAdapter; use Symfony\Component\Cache\CacheItem; -/** - * @group integration - */ +#[Group('integration')] class ProxyAdapterAndRedisAdapterTest extends AbstractRedisAdapterTestCase { protected $skippedTests = [ diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php index 765dd7565dc76..ceab40f1270ea 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -18,9 +19,7 @@ use Symfony\Component\Cache\Adapter\ProxyAdapter; use Symfony\Component\Cache\CacheItem; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class ProxyAdapterTest extends AdapterTestCase { protected $skippedTests = [ diff --git a/src/Symfony/Component/Cache/Tests/Adapter/Psr16AdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/Psr16AdapterTest.php index bdd5d04c564b6..528f84ba833bf 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/Psr16AdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/Psr16AdapterTest.php @@ -11,15 +11,14 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\Psr16Adapter; use Symfony\Component\Cache\Psr16Cache; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class Psr16AdapterTest extends AdapterTestCase { protected $skippedTests = [ diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php index 9103eec59622d..5a669efb6cf37 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php @@ -11,13 +11,12 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\RedisAdapter; use Symfony\Component\Cache\Exception\InvalidArgumentException; -/** - * @group integration - */ +#[Group('integration')] class RedisAdapterSentinelTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php index 7b8e11ea5faf2..b116c2a46565b 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php @@ -11,15 +11,15 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\RedisAdapter; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\Traits\RedisProxy; -/** - * @group integration - */ +#[Group('integration')] class RedisAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void @@ -95,9 +95,7 @@ public function testCreateTlsConnection() $this->assertInstanceOf(RedisProxy::class, $redis); } - /** - * @dataProvider provideFailedCreateConnection - */ + #[DataProvider('provideFailedCreateConnection')] public function testFailedCreateConnection(string $dsn) { $this->expectException(InvalidArgumentException::class); @@ -115,9 +113,7 @@ public static function provideFailedCreateConnection(): array ]; } - /** - * @dataProvider provideInvalidCreateConnection - */ + #[DataProvider('provideInvalidCreateConnection')] public function testInvalidCreateConnection(string $dsn) { $this->expectException(InvalidArgumentException::class); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php index 22b07e872f6b9..a8cb5577e5ae8 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php @@ -11,9 +11,9 @@ namespace Symfony\Component\Cache\Tests\Adapter; -/** - * @group integration - */ +use PHPUnit\Framework\Attributes\Group; + +#[Group('integration')] class RedisArrayAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php index 3b7450e139254..319140f8c74e7 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php @@ -11,15 +11,15 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\RedisAdapter; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\Traits\RedisClusterProxy; -/** - * @group integration - */ +#[Group('integration')] class RedisClusterAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void @@ -47,9 +47,7 @@ public function createCachePool(int $defaultLifetime = 0, ?string $testMethod = return $adapter; } - /** - * @dataProvider provideFailedCreateConnection - */ + #[DataProvider('provideFailedCreateConnection')] public function testFailedCreateConnection(string $dsn) { $this->expectException(InvalidArgumentException::class); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareAdapterTest.php index f00eb9de8aaeb..3ae641d9a8442 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareAdapterTest.php @@ -11,13 +11,12 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; use Symfony\Component\Cache\Traits\RedisProxy; -/** - * @group integration - */ +#[Group('integration')] class RedisTagAwareAdapterTest extends RedisAdapterTest { use TagAwareTestTrait; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareArrayAdapterTest.php index 860709bf7f2cb..e0bb366dfdab0 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareArrayAdapterTest.php @@ -11,12 +11,11 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; -/** - * @group integration - */ +#[Group('integration')] class RedisTagAwareArrayAdapterTest extends RedisArrayAdapterTest { use TagAwareTestTrait; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareClusterAdapterTest.php index c7d143d3a35db..30c65e4f6a142 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareClusterAdapterTest.php @@ -11,13 +11,12 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; use Symfony\Component\Cache\Traits\RedisClusterProxy; -/** - * @group integration - */ +#[Group('integration')] class RedisTagAwareClusterAdapterTest extends RedisClusterAdapterTest { use TagAwareTestTrait; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareRelayClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareRelayClusterAdapterTest.php index 4939d2dfe1466..3b1ebdf28748b 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareRelayClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareRelayClusterAdapterTest.php @@ -11,15 +11,14 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; use Symfony\Component\Cache\Traits\RelayClusterProxy; -/** - * @requires extension relay - * - * @group integration - */ +#[RequiresPhpExtension('relay')] +#[Group('integration')] class RedisTagAwareRelayClusterAdapterTest extends RelayClusterAdapterTest { use TagAwareTestTrait; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RelayAdapterSentinelTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RelayAdapterSentinelTest.php index 91a7da460167f..61dc1ae9fbbdb 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RelayAdapterSentinelTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RelayAdapterSentinelTest.php @@ -11,13 +11,12 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Relay\Relay; use Relay\Sentinel; use Symfony\Component\Cache\Adapter\AbstractAdapter; -/** - * @group integration - */ +#[Group('integration')] class RelayAdapterSentinelTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RelayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RelayAdapterTest.php index dde78f4342fc8..6162abd1e8b85 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RelayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RelayAdapterTest.php @@ -11,17 +11,16 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use Relay\Relay; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\RedisAdapter; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\Traits\RelayProxy; -/** - * @requires extension relay - * - * @group integration - */ +#[RequiresPhpExtension('relay')] +#[Group('integration')] class RelayAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RelayClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RelayClusterAdapterTest.php index 56363f8204345..b0c8264635c64 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RelayClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RelayClusterAdapterTest.php @@ -11,6 +11,9 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use Psr\Cache\CacheItemPoolInterface; use Relay\Cluster as RelayCluster; use Relay\Relay; @@ -19,11 +22,8 @@ use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\Traits\RelayClusterProxy; -/** - * @requires extension relay - * - * @group integration - */ +#[RequiresPhpExtension('relay')] +#[Group('integration')] class RelayClusterAdapterTest extends AbstractRedisAdapterTestCase { public static function setUpBeforeClass(): void @@ -47,9 +47,7 @@ public function createCachePool(int $defaultLifetime = 0, ?string $testMethod = return $adapter; } - /** - * @dataProvider provideFailedCreateConnection - */ + #[DataProvider('provideFailedCreateConnection')] public function testFailedCreateConnection(string $dsn) { $this->expectException(InvalidArgumentException::class); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php index a85ef77e132e4..58edd522cc9ae 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\AdapterInterface; @@ -21,9 +23,7 @@ use Symfony\Component\Cache\Tests\Fixtures\PrunableAdapter; use Symfony\Component\Filesystem\Filesystem; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class TagAwareAdapterTest extends AdapterTestCase { use TagAwareTestTrait; @@ -128,9 +128,7 @@ private function getNonPruneableMock(): AdapterInterface&MockObject return $this->createMock(AdapterInterface::class); } - /** - * @doesNotPerformAssertions - */ + #[DoesNotPerformAssertions] public function testToleranceForStringsAsTagVersionsCase1() { $pool = $this->createCachePool(); @@ -145,9 +143,7 @@ public function testToleranceForStringsAsTagVersionsCase1() $pool->getItem($itemKey); } - /** - * @doesNotPerformAssertions - */ + #[DoesNotPerformAssertions] public function testToleranceForStringsAsTagVersionsCase2() { $pool = $this->createCachePool(); @@ -163,9 +159,7 @@ public function testToleranceForStringsAsTagVersionsCase2() $pool->hasItem($itemKey); } - /** - * @doesNotPerformAssertions - */ + #[DoesNotPerformAssertions] public function testToleranceForStringsAsTagVersionsCase3() { $pool = $this->createCachePool(); @@ -187,9 +181,7 @@ public function testToleranceForStringsAsTagVersionsCase3() $pool->hasItem($itemKey); } - /** - * @doesNotPerformAssertions - */ + #[DoesNotPerformAssertions] public function testToleranceForStringsAsTagVersionsCase4() { $pool = $this->createCachePool(); @@ -209,9 +201,7 @@ public function testToleranceForStringsAsTagVersionsCase4() $pool->getItem($itemKey); } - /** - * @doesNotPerformAssertions - */ + #[DoesNotPerformAssertions] public function testToleranceForStringsAsTagVersionsCase5() { $pool = $this->createCachePool(); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAndProxyAdapterIntegrationTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAndProxyAdapterIntegrationTest.php index 4af199dc417cd..c666f73cc8fb9 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAndProxyAdapterIntegrationTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAndProxyAdapterIntegrationTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -20,9 +21,7 @@ class TagAwareAndProxyAdapterIntegrationTest extends TestCase { - /** - * @dataProvider dataProvider - */ + #[DataProvider('dataProvider')] public function testIntegrationUsingProxiedAdapter(CacheItemPoolInterface $proxiedAdapter) { $cache = new TagAwareAdapter(new ProxyAdapter($proxiedAdapter)); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TraceableAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TraceableAdapterTest.php index 3a573dc4314ed..b2c6cf84957b4 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TraceableAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TraceableAdapterTest.php @@ -11,13 +11,12 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\TraceableAdapter; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class TraceableAdapterTest extends AdapterTestCase { protected $skippedTests = [ diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TraceableTagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TraceableTagAwareAdapterTest.php index 5cd4185cb0971..7f69c33c3634a 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TraceableTagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TraceableTagAwareAdapterTest.php @@ -11,13 +11,12 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\TagAwareAdapter; use Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class TraceableTagAwareAdapterTest extends TraceableAdapterTest { public function testInvalidateTags() diff --git a/src/Symfony/Component/Cache/Tests/CacheItemTest.php b/src/Symfony/Component/Cache/Tests/CacheItemTest.php index 49ee1af4ffa50..284ae430c1978 100644 --- a/src/Symfony/Component/Cache/Tests/CacheItemTest.php +++ b/src/Symfony/Component/Cache/Tests/CacheItemTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\Exception\InvalidArgumentException; @@ -24,9 +25,7 @@ public function testValidKey() $this->assertSame('foo', CacheItem::validateKey('foo')); } - /** - * @dataProvider provideInvalidKey - */ + #[DataProvider('provideInvalidKey')] public function testInvalidKey($key) { $this->expectException(InvalidArgumentException::class); @@ -71,9 +70,7 @@ public function testTag() }, $this, CacheItem::class))(); } - /** - * @dataProvider provideInvalidKey - */ + #[DataProvider('provideInvalidKey')] public function testInvalidTag($tag) { $item = new CacheItem(); diff --git a/src/Symfony/Component/Cache/Tests/Marshaller/DefaultMarshallerTest.php b/src/Symfony/Component/Cache/Tests/Marshaller/DefaultMarshallerTest.php index a5578d963ab92..c089c065345a3 100644 --- a/src/Symfony/Component/Cache/Tests/Marshaller/DefaultMarshallerTest.php +++ b/src/Symfony/Component/Cache/Tests/Marshaller/DefaultMarshallerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Marshaller; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Marshaller\DefaultMarshaller; @@ -29,9 +30,7 @@ public function testSerialize() $this->assertSame(['b'], $failed); } - /** - * @requires extension igbinary - */ + #[RequiresPhpExtension('igbinary')] public function testIgbinarySerialize() { if (version_compare('3.1.6', phpversion('igbinary'), '>')) { @@ -58,9 +57,7 @@ public function testNativeUnserialize() $this->assertSame(0, $marshaller->unmarshall(serialize(0))); } - /** - * @requires extension igbinary - */ + #[RequiresPhpExtension('igbinary')] public function testIgbinaryUnserialize() { if (version_compare('3.1.6', phpversion('igbinary'), '>')) { @@ -81,9 +78,7 @@ public function testNativeUnserializeNotFoundClass() (new DefaultMarshaller())->unmarshall('O:16:"NotExistingClass":0:{}'); } - /** - * @requires extension igbinary - */ + #[RequiresPhpExtension('igbinary')] public function testIgbinaryUnserializeNotFoundClass() { if (version_compare('3.1.6', phpversion('igbinary'), '>')) { @@ -109,9 +104,7 @@ public function testNativeUnserializeInvalid() } } - /** - * @requires extension igbinary - */ + #[RequiresPhpExtension('igbinary')] public function testIgbinaryUnserializeInvalid() { if (version_compare('3.1.6', phpversion('igbinary'), '>')) { diff --git a/src/Symfony/Component/Cache/Tests/Marshaller/DeflateMarshallerTest.php b/src/Symfony/Component/Cache/Tests/Marshaller/DeflateMarshallerTest.php index 5caf5ebb24eb6..aca57f0ad1c86 100644 --- a/src/Symfony/Component/Cache/Tests/Marshaller/DeflateMarshallerTest.php +++ b/src/Symfony/Component/Cache/Tests/Marshaller/DeflateMarshallerTest.php @@ -11,13 +11,12 @@ namespace Symfony\Component\Cache\Tests\Marshaller; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Marshaller\DefaultMarshaller; use Symfony\Component\Cache\Marshaller\DeflateMarshaller; -/** - * @requires extension zlib - */ +#[RequiresPhpExtension('zlib')] class DeflateMarshallerTest extends TestCase { public function testMarshall() diff --git a/src/Symfony/Component/Cache/Tests/Marshaller/SodiumMarshallerTest.php b/src/Symfony/Component/Cache/Tests/Marshaller/SodiumMarshallerTest.php index e26151c07216a..cb9027a4d3ad5 100644 --- a/src/Symfony/Component/Cache/Tests/Marshaller/SodiumMarshallerTest.php +++ b/src/Symfony/Component/Cache/Tests/Marshaller/SodiumMarshallerTest.php @@ -11,13 +11,12 @@ namespace Symfony\Component\Cache\Tests\Marshaller; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Marshaller\DefaultMarshaller; use Symfony\Component\Cache\Marshaller\SodiumMarshaller; -/** - * @requires extension sodium - */ +#[RequiresPhpExtension('sodium')] class SodiumMarshallerTest extends TestCase { private string $decryptionKey; diff --git a/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationHandlerTest.php b/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationHandlerTest.php index 963215df719b6..059f42032392e 100644 --- a/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationHandlerTest.php +++ b/src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationHandlerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Messenger; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Psr\Cache\CacheItemInterface; use Symfony\Component\Cache\Adapter\FilesystemAdapter; @@ -29,9 +30,7 @@ public static function tearDownAfterClass(): void (new Filesystem())->remove(sys_get_temp_dir().'/symfony-cache'); } - /** - * @group time-sensitive - */ + #[Group('time-sensitive')] public function testHandle() { $pool = new FilesystemAdapter(); diff --git a/src/Symfony/Component/Cache/Tests/Psr16CacheTest.php b/src/Symfony/Component/Cache/Tests/Psr16CacheTest.php index b5a1fe489d423..9f0d43e901bc8 100644 --- a/src/Symfony/Component/Cache/Tests/Psr16CacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Psr16CacheTest.php @@ -12,14 +12,13 @@ namespace Symfony\Component\Cache\Tests; use Cache\IntegrationTests\SimpleCacheTest; +use PHPUnit\Framework\Attributes\Group; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\Psr16Cache; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class Psr16CacheTest extends SimpleCacheTest { protected function setUp(): void diff --git a/src/Symfony/Component/Cache/Tests/Psr16CacheWithExternalAdapter.php b/src/Symfony/Component/Cache/Tests/Psr16CacheWithExternalAdapter.php index 39eba832b80a4..4cbbab83b0d25 100644 --- a/src/Symfony/Component/Cache/Tests/Psr16CacheWithExternalAdapter.php +++ b/src/Symfony/Component/Cache/Tests/Psr16CacheWithExternalAdapter.php @@ -12,13 +12,12 @@ namespace Symfony\Component\Cache\Tests; use Cache\IntegrationTests\SimpleCacheTest; +use PHPUnit\Framework\Attributes\Group; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\Psr16Cache; use Symfony\Component\Cache\Tests\Fixtures\ExternalAdapter; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class Psr16CacheWithExternalAdapter extends SimpleCacheTest { protected function setUp(): void diff --git a/src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php b/src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php index c87814f4334d8..0a7f69cb989fc 100644 --- a/src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php +++ b/src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Cache\Tests\Traits; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Relay\Cluster as RelayCluster; use Relay\Relay; @@ -21,12 +23,9 @@ class RedisProxiesTest extends TestCase { - /** - * @requires extension redis - * - * @testWith ["Redis"] - * ["RedisCluster"] - */ + #[RequiresPhpExtension('redis')] + #[TestWith([\Redis::class])] + #[TestWith([\RedisCluster::class])] public function testRedisProxy($class) { $proxy = file_get_contents(\dirname(__DIR__, 2)."/Traits/{$class}Proxy.php"); @@ -75,9 +74,7 @@ public function testRedisProxy($class) $this->assertSame($expected, $proxy); } - /** - * @requires extension relay - */ + #[RequiresPhpExtension('relay')] public function testRelayProxy() { $proxy = file_get_contents(\dirname(__DIR__, 2).'/Traits/RelayProxy.php'); @@ -122,9 +119,7 @@ public function testRelayProxy() $this->assertEquals($expectedProxy, $proxy); } - /** - * @requires extension relay - */ + #[RequiresPhpExtension('relay')] public function testRelayClusterProxy() { $proxy = file_get_contents(\dirname(__DIR__, 2).'/Traits/RelayClusterProxy.php'); diff --git a/src/Symfony/Component/Cache/Tests/Traits/RedisTraitTest.php b/src/Symfony/Component/Cache/Tests/Traits/RedisTraitTest.php index 3a533d0c09f35..9a4e70c4a85dd 100644 --- a/src/Symfony/Component/Cache/Tests/Traits/RedisTraitTest.php +++ b/src/Symfony/Component/Cache/Tests/Traits/RedisTraitTest.php @@ -11,18 +11,17 @@ namespace Symfony\Component\Cache\Tests\Traits; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\Traits\RedisTrait; -/** - * @requires extension redis - */ +#[RequiresPhpExtension('redis')] class RedisTraitTest extends TestCase { - /** - * @dataProvider provideCreateConnection - */ + #[DataProvider('provideCreateConnection')] public function testCreateConnection(string $dsn, string $expectedClass) { if (!class_exists($expectedClass)) { @@ -84,9 +83,8 @@ public static function provideCreateConnection(): array * a persistent connection, the database has to be re-selected, too. * * @see https://github.com/phpredis/phpredis/issues/1920 - * - * @group integration */ + #[Group('integration')] public function testPconnectSelectsCorrectDatabase() { if (!class_exists(\Redis::class)) { @@ -134,9 +132,7 @@ public function testPconnectSelectsCorrectDatabase() } } - /** - * @dataProvider provideDbIndexDsnParameter - */ + #[DataProvider('provideDbIndexDsnParameter')] public function testDbIndexDsnParameter(string $dsn, int $expectedDb) { if (!getenv('REDIS_AUTHENTICATED_HOST')) { @@ -180,9 +176,7 @@ public static function provideDbIndexDsnParameter(): array ]; } - /** - * @dataProvider provideInvalidDbIndexDsnParameter - */ + #[DataProvider('provideInvalidDbIndexDsnParameter')] public function testInvalidDbIndexDsnParameter(string $dsn) { if (!getenv('REDIS_AUTHENTICATED_HOST')) { diff --git a/src/Symfony/Component/Clock/Tests/DatePointTest.php b/src/Symfony/Component/Clock/Tests/DatePointTest.php index c3f3ce7116275..261476b327dc0 100644 --- a/src/Symfony/Component/Clock/Tests/DatePointTest.php +++ b/src/Symfony/Component/Clock/Tests/DatePointTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Clock\Tests; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\Component\Clock\DatePoint; use Symfony\Component\Clock\Test\ClockSensitiveTrait; @@ -45,9 +47,7 @@ public function testCreateFromFormat() DatePoint::createFromFormat('Y-m-d H:i:s', 'Bad Date'); } - /** - * @dataProvider provideValidTimestamps - */ + #[DataProvider('provideValidTimestamps')] public function testCreateFromTimestamp(int|float $timestamp, string $expected) { $date = DatePoint::createFromTimestamp($timestamp); @@ -68,9 +68,7 @@ public static function provideValidTimestamps(): iterable yield 'negative integer-ish float' => [-100.0, '1969-12-31T23:58:20.000000+00:00']; } - /** - * @dataProvider provideOutOfRangeFloatTimestamps - */ + #[DataProvider('provideOutOfRangeFloatTimestamps')] public function testCreateFromTimestampWithFloatOutOfRange(float $timestamp) { $this->expectException(\DateRangeError::class); @@ -115,12 +113,10 @@ public function testMicrosecond() $date->setMicrosecond(1000000); } - /** - * @testWith ["2024-04-01 00:00:00.000000", "2024-04"] - * ["2024-04-09 00:00:00.000000", "2024-04-09"] - * ["2024-04-09 03:00:00.000000", "2024-04-09 03:00"] - * ["2024-04-09 00:00:00.123456", "2024-04-09 00:00:00.123456"] - */ + #[TestWith(['2024-04-01 00:00:00.000000', '2024-04'])] + #[TestWith(['2024-04-09 00:00:00.000000', '2024-04-09'])] + #[TestWith(['2024-04-09 03:00:00.000000', '2024-04-09 03:00'])] + #[TestWith(['2024-04-09 00:00:00.123456', '2024-04-09 00:00:00.123456'])] public function testTimeDefaultsToMidnight(string $expected, string $datetime) { $date = new \DateTimeImmutable($datetime); diff --git a/src/Symfony/Component/Clock/Tests/MockClockTest.php b/src/Symfony/Component/Clock/Tests/MockClockTest.php index f54c27e78dd25..3fd4af67b2890 100644 --- a/src/Symfony/Component/Clock/Tests/MockClockTest.php +++ b/src/Symfony/Component/Clock/Tests/MockClockTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Clock\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Clock\MockClock; @@ -76,9 +77,7 @@ public static function provideValidModifyStrings(): iterable ]; } - /** - * @dataProvider provideValidModifyStrings - */ + #[DataProvider('provideValidModifyStrings')] public function testModifyWithSpecificDateTime(string $modifiedNow, string $expectedNow) { $clock = new MockClock((new \DateTimeImmutable('2112-09-17 23:53:00.999Z'))->setTimezone(new \DateTimeZone('UTC'))); @@ -96,9 +95,7 @@ public static function provideInvalidModifyStrings(): iterable yield 'empty string' => ['']; } - /** - * @dataProvider provideInvalidModifyStrings - */ + #[DataProvider('provideInvalidModifyStrings')] public function testModifyThrowsOnInvalidString(string $modifiedNow) { $clock = new MockClock((new \DateTimeImmutable('2112-09-17 23:53:00.999Z'))->setTimezone(new \DateTimeZone('UTC'))); diff --git a/src/Symfony/Component/Clock/Tests/MonotonicClockTest.php b/src/Symfony/Component/Clock/Tests/MonotonicClockTest.php index 54cfe78c375cc..1274d5891816d 100644 --- a/src/Symfony/Component/Clock/Tests/MonotonicClockTest.php +++ b/src/Symfony/Component/Clock/Tests/MonotonicClockTest.php @@ -11,12 +11,11 @@ namespace Symfony\Component\Clock\Tests; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Symfony\Component\Clock\MonotonicClock; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class MonotonicClockTest extends TestCase { public function testConstruct() diff --git a/src/Symfony/Component/Config/Tests/Builder/GeneratedConfigTest.php b/src/Symfony/Component/Config/Tests/Builder/GeneratedConfigTest.php index 856bcf279575e..2dcff85ec80dd 100644 --- a/src/Symfony/Component/Config/Tests/Builder/GeneratedConfigTest.php +++ b/src/Symfony/Component/Config/Tests/Builder/GeneratedConfigTest.php @@ -11,10 +11,14 @@ namespace Symfony\Component\Config\Tests\Builder; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Builder\ClassBuilder; use Symfony\Component\Config\Builder\ConfigBuilderGenerator; use Symfony\Component\Config\Builder\ConfigBuilderInterface; +use Symfony\Component\Config\Builder\Method; +use Symfony\Component\Config\Builder\Property; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\Tests\Builder\Fixtures\AddToList; use Symfony\Component\Config\Tests\Builder\Fixtures\NodeInitialValues; @@ -28,12 +32,11 @@ * Test to use the generated config and test its output. * * @author Tobias Nyholm - * - * @covers \Symfony\Component\Config\Builder\ClassBuilder - * @covers \Symfony\Component\Config\Builder\ConfigBuilderGenerator - * @covers \Symfony\Component\Config\Builder\Method - * @covers \Symfony\Component\Config\Builder\Property */ +#[CoversClass(ClassBuilder::class)] +#[CoversClass(ConfigBuilderGenerator::class)] +#[CoversClass(Method::class)] +#[CoversClass(Property::class)] class GeneratedConfigTest extends TestCase { private array $tempDir = []; @@ -74,9 +77,7 @@ public static function fixtureNames() } } - /** - * @dataProvider fixtureNames - */ + #[DataProvider('fixtureNames')] public function testConfig(string $name, string $alias) { $basePath = __DIR__.'/Fixtures/'; diff --git a/src/Symfony/Component/Config/Tests/ConfigCacheTest.php b/src/Symfony/Component/Config/Tests/ConfigCacheTest.php index e639fb220ef8f..b4610e64f63c1 100644 --- a/src/Symfony/Component/Config/Tests/ConfigCacheTest.php +++ b/src/Symfony/Component/Config/Tests/ConfigCacheTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Config\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\ConfigCache; use Symfony\Component\Config\Resource\FileResource; @@ -39,9 +40,7 @@ protected function tearDown(): void } } - /** - * @dataProvider debugModes - */ + #[DataProvider('debugModes')] public function testCacheIsNotValidIfNothingHasBeenCached(bool $debug) { unlink($this->cacheFile); // remove tempnam() side effect @@ -61,9 +60,7 @@ public function testIsAlwaysFreshInProduction() $this->assertTrue($cache->isFresh()); } - /** - * @dataProvider debugModes - */ + #[DataProvider('debugModes')] public function testIsFreshWhenNoResourceProvided(bool $debug) { $cache = new ConfigCache($this->cacheFile, $debug); diff --git a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php index 5212ef7c7091a..f908be892eb72 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Config\Tests\Definition; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\ArrayNode; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; @@ -75,9 +76,7 @@ public static function ignoreAndRemoveMatrixProvider(): array ]; } - /** - * @dataProvider ignoreAndRemoveMatrixProvider - */ + #[DataProvider('ignoreAndRemoveMatrixProvider')] public function testIgnoreAndRemoveBehaviors(bool $ignore, bool $remove, array|\Exception $expected, string $message = '') { if ($expected instanceof \Exception) { @@ -90,9 +89,7 @@ public function testIgnoreAndRemoveBehaviors(bool $ignore, bool $remove, array|\ $this->assertSame($expected, $result, $message); } - /** - * @dataProvider getPreNormalizationTests - */ + #[DataProvider('getPreNormalizationTests')] public function testPreNormalize(array $denormalized, array $normalized) { $node = new ArrayNode('foo'); @@ -124,9 +121,7 @@ public static function getPreNormalizationTests(): array ]; } - /** - * @dataProvider getZeroNamedNodeExamplesData - */ + #[DataProvider('getZeroNamedNodeExamplesData')] public function testNodeNameCanBeZero(array $denormalized, array $normalized) { $zeroNode = new ArrayNode(0); @@ -171,9 +166,7 @@ public static function getZeroNamedNodeExamplesData(): array ]; } - /** - * @dataProvider getPreNormalizedNormalizedOrderedData - */ + #[DataProvider('getPreNormalizedNormalizedOrderedData')] public function testChildrenOrderIsMaintainedOnNormalizeValue(array $prenormalized, array $normalized) { $scalar1 = new ScalarNode('1'); @@ -276,9 +269,7 @@ public function testSetDeprecated() $this->assertTrue($deprecationTriggered, '->finalize() should trigger if the deprecated node is set'); } - /** - * @dataProvider getDataWithIncludedExtraKeys - */ + #[DataProvider('getDataWithIncludedExtraKeys')] public function testMergeWithoutIgnoringExtraKeys(array $prenormalizeds) { $node = new ArrayNode('root'); @@ -294,9 +285,7 @@ public function testMergeWithoutIgnoringExtraKeys(array $prenormalizeds) $r->invoke($node, ...$prenormalizeds); } - /** - * @dataProvider getDataWithIncludedExtraKeys - */ + #[DataProvider('getDataWithIncludedExtraKeys')] public function testMergeWithIgnoringAndRemovingExtraKeys(array $prenormalizeds) { $node = new ArrayNode('root'); @@ -312,9 +301,7 @@ public function testMergeWithIgnoringAndRemovingExtraKeys(array $prenormalizeds) $r->invoke($node, ...$prenormalizeds); } - /** - * @dataProvider getDataWithIncludedExtraKeys - */ + #[DataProvider('getDataWithIncludedExtraKeys')] public function testMergeWithIgnoringExtraKeys(array $prenormalizeds, array $merged) { $node = new ArrayNode('root'); diff --git a/src/Symfony/Component/Config/Tests/Definition/BaseNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/BaseNodeTest.php index f8d3f24f42ca7..6bfe717428421 100644 --- a/src/Symfony/Component/Config/Tests/Definition/BaseNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/BaseNodeTest.php @@ -11,15 +11,14 @@ namespace Symfony\Component\Config\Tests\Definition; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\BaseNode; use Symfony\Component\Config\Definition\NodeInterface; class BaseNodeTest extends TestCase { - /** - * @dataProvider providePath - */ + #[DataProvider('providePath')] public function testGetPathForChildNode(string $expected, array $params) { $constructorArgs = []; diff --git a/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php index 9358a975d0dd5..c5c7b33bc313b 100644 --- a/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php @@ -11,15 +11,14 @@ namespace Symfony\Component\Config\Tests\Definition; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\BooleanNode; use Symfony\Component\Config\Definition\Exception\InvalidTypeException; class BooleanNodeTest extends TestCase { - /** - * @dataProvider getValidValues - */ + #[DataProvider('getValidValues')] public function testNormalize(bool $value) { $node = new BooleanNode('test'); @@ -53,9 +52,7 @@ public function testInvalidValueOnNullable() $node->normalize(123); } - /** - * @dataProvider getValidValues - */ + #[DataProvider('getValidValues')] public function testValidNonEmptyValues(bool $value) { $node = new BooleanNode('test'); @@ -72,9 +69,7 @@ public static function getValidValues(): array ]; } - /** - * @dataProvider getInvalidValues - */ + #[DataProvider('getInvalidValues')] public function testNormalizeThrowsExceptionOnInvalidValues($value) { $node = new BooleanNode('test'); diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php index 281813a8cd0f1..ea8ee8f612dd8 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Config\Tests\Definition\Builder; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition; @@ -39,9 +40,7 @@ public function testAppendingSomeNode() $this->assertContains($child, $this->getField($parent, 'children')); } - /** - * @dataProvider providePrototypeNodeSpecificCalls - */ + #[DataProvider('providePrototypeNodeSpecificCalls')] public function testPrototypeNodeSpecificOption(string $method, array $args) { $this->expectException(InvalidDefinitionException::class); @@ -97,9 +96,7 @@ public function testPrototypedArrayNodeDefaultWhenUsingDefaultChildren() $this->assertEquals([[]], $tree->getDefaultValue()); } - /** - * @dataProvider providePrototypedArrayNodeDefaults - */ + #[DataProvider('providePrototypedArrayNodeDefaults')] public function testPrototypedArrayNodeDefault(int|array|string|null $args, bool $shouldThrowWhenUsingAttrAsKey, bool $shouldThrowWhenNotUsingAttrAsKey, array $defaults) { $node = new ArrayNodeDefinition('root'); @@ -170,9 +167,7 @@ public function testEnabledNodeDefaults() $this->assertEquals(['enabled' => false, 'foo' => 'bar'], $node->getNode()->getDefaultValue()); } - /** - * @dataProvider getEnableableNodeFixtures - */ + #[DataProvider('getEnableableNodeFixtures')] public function testTrueEnableEnabledNode(array $expected, array $config, string $message) { $processor = new Processor(); diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php index d1447376e270c..eb13db4c83985 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Config\Tests\Definition\Builder; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\ExprBuilder; use Symfony\Component\Config\Definition\Builder\NodeDefinition; @@ -193,9 +194,7 @@ public function testThenEmptyArrayExpression() $this->assertFinalizedValueIs([], $test); } - /** - * @dataProvider castToArrayValues - */ + #[DataProvider('castToArrayValues')] public function testCastToArrayExpression($configValue, array $expectedValue) { $test = $this->getTestBuilder() diff --git a/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php b/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php index 534372bc6eace..f566e9ebffc96 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Config\Tests\Definition\Dumper; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper; use Symfony\Component\Config\Tests\Fixtures\Configuration\ExampleConfiguration; @@ -69,9 +70,7 @@ public static function provideDumpAtPath(): array ]; } - /** - * @dataProvider provideDumpAtPath - */ + #[DataProvider('provideDumpAtPath')] public function testDumpAtPath(string $path, string $expected) { $configuration = new ExampleConfiguration(); diff --git a/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php index 9d18b5899682c..f125886912b83 100644 --- a/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php @@ -11,24 +11,21 @@ namespace Symfony\Component\Config\Tests\Definition; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Exception\InvalidTypeException; use Symfony\Component\Config\Definition\FloatNode; class FloatNodeTest extends TestCase { - /** - * @dataProvider getValidValues - */ + #[DataProvider('getValidValues')] public function testNormalize(int|float $value) { $node = new FloatNode('test'); $this->assertSame($value, $node->normalize($value)); } - /** - * @dataProvider getValidValues - */ + #[DataProvider('getValidValues')] public function testValidNonEmptyValues(int|float $value) { $node = new FloatNode('test'); @@ -51,9 +48,7 @@ public static function getValidValues(): array ]; } - /** - * @dataProvider getInvalidValues - */ + #[DataProvider('getInvalidValues')] public function testNormalizeThrowsExceptionOnInvalidValues($value) { $node = new FloatNode('test'); diff --git a/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php index 6ab60032d23b1..eff9fc66c908c 100644 --- a/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php @@ -11,24 +11,21 @@ namespace Symfony\Component\Config\Tests\Definition; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Exception\InvalidTypeException; use Symfony\Component\Config\Definition\IntegerNode; class IntegerNodeTest extends TestCase { - /** - * @dataProvider getValidValues - */ + #[DataProvider('getValidValues')] public function testNormalize(int $value) { $node = new IntegerNode('test'); $this->assertSame($value, $node->normalize($value)); } - /** - * @dataProvider getValidValues - */ + #[DataProvider('getValidValues')] public function testValidNonEmptyValues(int $value) { $node = new IntegerNode('test'); @@ -46,9 +43,7 @@ public static function getValidValues(): array ]; } - /** - * @dataProvider getInvalidValues - */ + #[DataProvider('getInvalidValues')] public function testNormalizeThrowsExceptionOnInvalidValues($value) { $node = new IntegerNode('test'); diff --git a/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php b/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php index 3bf489ee1b50d..195403bb9d478 100644 --- a/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Config\Tests\Definition; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; @@ -18,9 +19,7 @@ class NormalizationTest extends TestCase { - /** - * @dataProvider getEncoderTests - */ + #[DataProvider('getEncoderTests')] public function testNormalizeEncoders($denormalized) { $tb = new TreeBuilder('root_name', 'array'); @@ -91,9 +90,7 @@ public static function getEncoderTests(): array return array_map(fn ($v) => [$v], $configs); } - /** - * @dataProvider getAnonymousKeysTests - */ + #[DataProvider('getAnonymousKeysTests')] public function testAnonymousKeysArray($denormalized) { $tb = new TreeBuilder('root', 'array'); @@ -137,9 +134,7 @@ public static function getAnonymousKeysTests(): array return array_map(fn ($v) => [$v], $configs); } - /** - * @dataProvider getNumericKeysTests - */ + #[DataProvider('getNumericKeysTests')] public function testNumericKeysAsAttributes($denormalized) { $normalized = [ diff --git a/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php index f33a79ff0477e..4f199191d53cc 100644 --- a/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Config\Tests\Definition; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\ArrayNode; use Symfony\Component\Config\Definition\PrototypedArrayNode; @@ -261,9 +262,8 @@ protected function getPrototypeNodeWithDefaultChildren() * 'option2' => 'value2' * ] * ] - * - * @dataProvider getDataForKeyRemovedLeftValueOnly */ + #[DataProvider('getDataForKeyRemovedLeftValueOnly')] public function testMappedAttributeKeyIsRemovedLeftValueOnly($value, array $children, array $expected) { $node = new PrototypedArrayNode('root'); @@ -339,9 +339,7 @@ public static function getDataForKeyRemovedLeftValueOnly(): array ]; } - /** - * @dataProvider getPrototypedArrayNodeDataToMerge - */ + #[DataProvider('getPrototypedArrayNodeDataToMerge')] public function testPrototypedArrayNodeMerge(array $left, array $right, array $expected) { $node = new PrototypedArrayNode('options'); diff --git a/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php index 9ccd910c2863e..418e8eae0b8b0 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Config\Tests\Definition; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\ArrayNode; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; @@ -19,9 +20,7 @@ class ScalarNodeTest extends TestCase { - /** - * @dataProvider getValidValues - */ + #[DataProvider('getValidValues')] public function testNormalize($value) { $node = new ScalarNode('test'); @@ -83,9 +82,7 @@ public function testSetDeprecated() $this->assertSame(1, $deprecationTriggered, '->finalize() should trigger if the deprecated node is set'); } - /** - * @dataProvider getInvalidValues - */ + #[DataProvider('getInvalidValues')] public function testNormalizeThrowsExceptionOnInvalidValues($value) { $node = new ScalarNode('test'); @@ -125,9 +122,7 @@ public function testNormalizeThrowsExceptionWithErrorMessage() $node->normalize([]); } - /** - * @dataProvider getValidNonEmptyValues - */ + #[DataProvider('getValidNonEmptyValues')] public function testValidNonEmptyValues($value) { $node = new ScalarNode('test'); @@ -149,11 +144,7 @@ public static function getValidNonEmptyValues(): array ]; } - /** - * @dataProvider getEmptyValues - * - * @param mixed $value - */ + #[DataProvider('getEmptyValues')] public function testNotAllowedEmptyValuesThrowException($value) { $node = new ScalarNode('test'); diff --git a/src/Symfony/Component/Config/Tests/Definition/StringNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/StringNodeTest.php index ddc219d243657..177fe94657a7b 100644 --- a/src/Symfony/Component/Config/Tests/Definition/StringNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/StringNodeTest.php @@ -11,33 +11,30 @@ namespace Symfony\Component\Config\Tests\Definition; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Exception\InvalidTypeException; use Symfony\Component\Config\Definition\StringNode; class StringNodeTest extends TestCase { - /** - * @testWith [""] - * ["valid string"] - */ + #[TestWith([''])] + #[TestWith(['valid string'])] public function testNormalize(string $value) { $node = new StringNode('test'); $this->assertSame($value, $node->normalize($value)); } - /** - * @testWith [null] - * [false] - * [true] - * [0] - * [1] - * [0.0] - * [0.1] - * [{}] - * [{"foo": "bar"}] - */ + #[TestWith([null])] + #[TestWith([false])] + #[TestWith([true])] + #[TestWith([0])] + #[TestWith([1])] + #[TestWith([0.0])] + #[TestWith([0.1])] + #[TestWith([[]])] + #[TestWith([['foo' => 'bar']])] public function testNormalizeThrowsExceptionOnInvalidValues($value) { $node = new StringNode('test'); diff --git a/src/Symfony/Component/Config/Tests/FileLocatorTest.php b/src/Symfony/Component/Config/Tests/FileLocatorTest.php index beb005a3517ff..e0db3db317883 100644 --- a/src/Symfony/Component/Config/Tests/FileLocatorTest.php +++ b/src/Symfony/Component/Config/Tests/FileLocatorTest.php @@ -11,15 +11,14 @@ namespace Symfony\Component\Config\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException; use Symfony\Component\Config\FileLocator; class FileLocatorTest extends TestCase { - /** - * @dataProvider getIsAbsolutePathTests - */ + #[DataProvider('getIsAbsolutePathTests')] public function testIsAbsolutePath(string $path) { $loader = new FileLocator([]); diff --git a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php index 4ee8fb0769fe2..fba77527496a3 100644 --- a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Config\Tests\Loader; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException; use Symfony\Component\Config\FileLocator; @@ -130,9 +131,7 @@ public function testImportWithExclude() $this->assertNotContains('ExcludeFile.txt', $loadedFiles); } - /** - * @dataProvider excludeTrailingSlashConsistencyProvider - */ + #[DataProvider('excludeTrailingSlashConsistencyProvider')] public function testExcludeTrailingSlashConsistency(string $exclude) { $loader = new TestFileLoader(new FileLocator(__DIR__.'/../Fixtures')); diff --git a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php index 26c5088636aaa..e9d4906c2c7c6 100644 --- a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Config\Tests\Resource; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\ReflectionClassResource; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -60,9 +61,7 @@ public function testIsFreshForDeletedResources() $this->assertFalse($res->isFresh($now), '->isFresh() returns false if the resource does not exist'); } - /** - * @dataProvider provideHashedSignature - */ + #[DataProvider('provideHashedSignature')] public function testHashedSignature(bool $changeExpected, int $changedLine, ?string $changedCode, int $resourceClassNameSuffix, ?\Closure $setContext = null) { if ($setContext) { diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index 2bc31e3bba421..722b18efa2c67 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Config\Tests\Util; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Util\Exception\InvalidXmlException; use Symfony\Component\Config\Util\XmlUtils; @@ -115,9 +116,7 @@ public function testLoadFileWithInternalErrorsEnabled() libxml_use_internal_errors($internalErrors); } - /** - * @dataProvider getDataForConvertDomToArray - */ + #[DataProvider('getDataForConvertDomToArray')] public function testConvertDomToArray($expected, string $xml, bool $root = false, bool $checkPrefix = true) { $dom = new \DOMDocument(); @@ -149,9 +148,7 @@ public static function getDataForConvertDomToArray(): array ]; } - /** - * @dataProvider getDataForPhpize - */ + #[DataProvider('getDataForPhpize')] public function testPhpize($expected, string $value) { $this->assertSame($expected, XmlUtils::phpize($value)); diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index f7ac71ef54f72..684ebeb91ef15 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -11,6 +11,10 @@ namespace Symfony\Component\Console\Tests; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; use Symfony\Component\Console\Attribute\AsCommand; @@ -272,9 +276,7 @@ public function testAddCommandWithInvokableExtendedCommand() $this->assertEquals($foo, $commands['invokable:test']); } - /** - * @dataProvider provideInvalidInvokableCommands - */ + #[DataProvider('provideInvalidInvokableCommands')] public function testAddCommandThrowsExceptionOnInvalidCommand(callable $command, string $expectedException, string $expectedExceptionMessage) { $application = new Application(); @@ -492,9 +494,7 @@ public function testFindWithCommandLoader() $this->assertInstanceOf(\FooCommand::class, $application->find('a'), '->find() returns a command if the abbreviation exists for an alias'); } - /** - * @dataProvider provideAmbiguousAbbreviations - */ + #[DataProvider('provideAmbiguousAbbreviations')] public function testFindWithAmbiguousAbbreviations($abbreviation, $expectedExceptionMessage) { putenv('COLUMNS=120'); @@ -567,9 +567,7 @@ public function testFindCommandWithMissingNamespace() $this->assertInstanceOf(\Foo4Command::class, $application->find('f::t')); } - /** - * @dataProvider provideInvalidCommandNamesSingle - */ + #[DataProvider('provideInvalidCommandNamesSingle')] public function testFindAlternativeExceptionMessageSingle($name) { $application = new Application(); @@ -841,10 +839,8 @@ public function testFindAmbiguousCommandsIfAllAlternativesAreHidden() $this->assertInstanceOf(\FooCommand::class, $application->find('foo:')); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testSetCatchExceptions(bool $catchErrors) { $application = new Application(); @@ -873,10 +869,8 @@ public function testSetCatchExceptions(bool $catchErrors) } } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testSetCatchErrors(bool $catchExceptions) { $application = new Application(); @@ -1015,9 +1009,7 @@ public function testRenderExceptionLineBreaks() $this->assertStringMatchesFormatFile(self::$fixturesPath.'/application_renderexception_linebreaks.txt', $tester->getDisplay(true), '->renderException() keep multiple line breaks'); } - /** - * @group transient-on-windows - */ + #[Group('transient-on-windows')] public function testRenderAnonymousException() { $application = new Application(); @@ -1041,9 +1033,7 @@ public function testRenderAnonymousException() $this->assertStringContainsString('Dummy type "class@anonymous" is invalid.', $tester->getDisplay(true)); } - /** - * @group transient-on-windows - */ + #[Group('transient-on-windows')] public function testRenderExceptionStackTraceContainsRootException() { $application = new Application(); @@ -1302,10 +1292,8 @@ public function testRunDispatchesExitCodeOneForExceptionCodeZero() $this->assertTrue($passedRightValue, '-> exit code 1 was passed in the console.terminate event'); } - /** - * @testWith [-1] - * [-32000] - */ + #[TestWith([-1])] + #[TestWith([-32000])] public function testRunReturnsExitCodeOneForNegativeExceptionCode($exceptionCode) { $exception = new \Exception('', $exceptionCode); @@ -1349,9 +1337,7 @@ public function testAddingOptionWithDuplicateShortcut() $application->run($input, $output); } - /** - * @dataProvider getAddingAlreadySetDefinitionElementData - */ + #[DataProvider('getAddingAlreadySetDefinitionElementData')] public function testAddingAlreadySetDefinitionElementData($def) { $application = new Application(); @@ -2039,9 +2025,7 @@ public function testCommandNameMismatchWithCommandLoaderKeyThrows() $app->get('test'); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testSignalListenerNotCalledByDefault() { $command = new SignableCommand(false); @@ -2059,9 +2043,7 @@ public function testSignalListenerNotCalledByDefault() $this->assertFalse($dispatcherCalled); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testSignalListener() { $command = new SignableCommand(); @@ -2080,9 +2062,7 @@ public function testSignalListener() $this->assertTrue($command->signaled); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testSignalSubscriberNotCalledByDefault() { $command = new BaseSignableCommand(false); @@ -2097,9 +2077,7 @@ public function testSignalSubscriberNotCalledByDefault() $this->assertFalse($subscriber->signaled); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testSignalSubscriber() { $command = new BaseSignableCommand(); @@ -2118,9 +2096,7 @@ public function testSignalSubscriber() $this->assertTrue($subscriber2->signaled); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testSignalDispatchWithoutEventToDispatch() { $command = new SignableCommand(); @@ -2132,9 +2108,7 @@ public function testSignalDispatchWithoutEventToDispatch() $this->assertTrue($command->signaled); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testSignalDispatchWithoutEventDispatcher() { $command = new SignableCommand(); @@ -2146,9 +2120,7 @@ public function testSignalDispatchWithoutEventDispatcher() $this->assertTrue($command->signaled); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testSetSignalsToDispatchEvent() { if (!\defined('SIGUSR1')) { @@ -2280,9 +2252,7 @@ public function testSignalableWithEventCommandDoesNotInterruptedOnTermSignals() $this->assertTrue($terminateEventDispatched); } - /** - * @group tty - */ + #[Group('tty')] public function testSignalableRestoresStty() { if (!Terminal::hasSttyAvailable()) { @@ -2313,9 +2283,7 @@ public function testSignalableRestoresStty() $this->assertSame($previousSttyMode, $sttyMode); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testSignalableInvokableCommand() { $command = new Command(); @@ -2331,9 +2299,7 @@ public function testSignalableInvokableCommand() $this->assertTrue($invokable->signaled); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testSignalableInvokableCommandThatExtendsBaseCommand() { $command = new class extends Command implements SignalableCommandInterface { @@ -2348,9 +2314,7 @@ public function testSignalableInvokableCommandThatExtendsBaseCommand() $this->assertTrue($command->signaled); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testAlarmSubscriberNotCalledByDefault() { $command = new BaseSignableCommand(false); @@ -2366,9 +2330,7 @@ public function testAlarmSubscriberNotCalledByDefault() $this->assertFalse($subscriber->signaled); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testAlarmSubscriberNotCalledForOtherSignals() { $command = new SignableCommand(); @@ -2387,9 +2349,7 @@ public function testAlarmSubscriberNotCalledForOtherSignals() $this->assertFalse($subscriber2->signaled); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testAlarmSubscriber() { $command = new BaseSignableCommand(signal: \SIGALRM); @@ -2408,9 +2368,7 @@ public function testAlarmSubscriber() $this->assertTrue($subscriber2->signaled); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testAlarmDispatchWithoutEventDispatcher() { $command = new AlarmableCommand(1); @@ -2423,9 +2381,7 @@ public function testAlarmDispatchWithoutEventDispatcher() $this->assertTrue($command->signaled); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testAlarmableCommandWithoutInterval() { $command = new AlarmableCommand(0); @@ -2442,9 +2398,7 @@ public function testAlarmableCommandWithoutInterval() $this->assertFalse($command->signaled); } - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testAlarmableCommandHandlerCalledAfterEventListener() { $command = new AlarmableCommand(1); @@ -2461,12 +2415,9 @@ public function testAlarmableCommandHandlerCalledAfterEventListener() $this->assertSame([AlarmEventSubscriber::class, AlarmableCommand::class], $command->signalHandlers); } - /** - * @requires extension pcntl - * - * @testWith [false] - * [4] - */ + #[RequiresPhpExtension('pcntl')] + #[TestWith([false])] + #[TestWith([4])] public function testAlarmSubscriberCalledAfterSignalSubscriberAndInheritsExitCode(int|false $exitCode) { $command = new BaseSignableCommand(signal: \SIGALRM); diff --git a/src/Symfony/Component/Console/Tests/CI/GithubActionReporterTest.php b/src/Symfony/Component/Console/Tests/CI/GithubActionReporterTest.php index a35927950d252..f4ee70eaf99f0 100644 --- a/src/Symfony/Component/Console/Tests/CI/GithubActionReporterTest.php +++ b/src/Symfony/Component/Console/Tests/CI/GithubActionReporterTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\CI; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\CI\GithubActionReporter; use Symfony\Component\Console\Output\BufferedOutput; @@ -31,9 +32,7 @@ public function testIsGithubActionEnvironment() } } - /** - * @dataProvider annotationsFormatProvider - */ + #[DataProvider('annotationsFormatProvider')] public function testAnnotationsFormat(string $type, string $message, ?string $file, ?int $line, ?int $col, string $expected) { $reporter = new GithubActionReporter($buffer = new BufferedOutput()); diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index 87c7b079012dd..f07b76a360ecc 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -11,8 +11,10 @@ namespace Symfony\Component\Console\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; use Symfony\Component\Console\Attribute\AsCommand; @@ -137,9 +139,7 @@ public function testGetNamespaceGetNameSetName() $this->assertEquals('foobar:bar', $command->getName(), '->setName() sets the command name'); } - /** - * @dataProvider provideInvalidCommandNames - */ + #[DataProvider('provideInvalidCommandNames')] public function testInvalidCommandNames($name) { $this->expectException(\InvalidArgumentException::class); @@ -205,10 +205,8 @@ public function testGetSetAliases() $this->assertEquals(['name1'], $command->getAliases(), '->setAliases() sets the aliases'); } - /** - * @testWith ["name|alias1|alias2", "name", ["alias1", "alias2"], false] - * ["|alias1|alias2", "alias1", ["alias2"], true] - */ + #[TestWith(['name|alias1|alias2', 'name', ['alias1', 'alias2'], false])] + #[TestWith(['|alias1|alias2', 'alias1', ['alias2'], true])] public function testSetAliasesAndHiddenViaName(string $name, string $expectedName, array $expectedAliases, bool $expectedHidden) { $command = new Command($name); @@ -390,9 +388,7 @@ public static function getSetCodeBindToClosureTests() ]; } - /** - * @dataProvider getSetCodeBindToClosureTests - */ + #[DataProvider('getSetCodeBindToClosureTests')] public function testSetCodeBindToClosure($previouslyBound, $expected) { $code = createClosure(); diff --git a/src/Symfony/Component/Console/Tests/Command/CompleteCommandTest.php b/src/Symfony/Component/Console/Tests/Command/CompleteCommandTest.php index 08f6b046ff7e4..8f26b036051ce 100644 --- a/src/Symfony/Component/Console/Tests/Command/CompleteCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CompleteCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; @@ -65,9 +66,7 @@ public function testAdditionalShellSupport() $this->execute(['--shell' => 'bash', '--current' => '1', '--input' => ['bin/console']]); } - /** - * @dataProvider provideInputAndCurrentOptionValues - */ + #[DataProvider('provideInputAndCurrentOptionValues')] public function testInputAndCurrentOptionValidation(array $input, ?string $exceptionMessage) { if ($exceptionMessage) { @@ -91,9 +90,7 @@ public static function provideInputAndCurrentOptionValues() yield [['--current' => '2', '--input' => ['bin/console', 'cache:clear']], null]; } - /** - * @dataProvider provideCompleteCommandNameInputs - */ + #[DataProvider('provideCompleteCommandNameInputs')] public function testCompleteCommandName(array $input, array $suggestions) { $this->execute(['--current' => '1', '--input' => $input]); @@ -108,9 +105,7 @@ public static function provideCompleteCommandNameInputs() yield 'complete-aliases' => [['bin/console', 'ah'], ['hello', 'ahoy']]; } - /** - * @dataProvider provideCompleteCommandInputDefinitionInputs - */ + #[DataProvider('provideCompleteCommandInputDefinitionInputs')] public function testCompleteCommandInputDefinition(array $input, array $suggestions) { $this->execute(['--current' => '2', '--input' => $input]); diff --git a/src/Symfony/Component/Console/Tests/Command/DumpCompletionCommandTest.php b/src/Symfony/Component/Console/Tests/Command/DumpCompletionCommandTest.php index ba23bb3311707..a69711e0ec2a2 100644 --- a/src/Symfony/Component/Console/Tests/Command/DumpCompletionCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/DumpCompletionCommandTest.php @@ -11,15 +11,14 @@ namespace Symfony\Component\Console\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Command\DumpCompletionCommand; use Symfony\Component\Console\Tester\CommandCompletionTester; class DumpCompletionCommandTest extends TestCase { - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions) { $tester = new CommandCompletionTester(new DumpCompletionCommand()); diff --git a/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php b/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php index f1979c0dc8475..160d78560e58b 100644 --- a/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\HelpCommand; @@ -70,9 +71,7 @@ public function testExecuteForApplicationCommandWithXmlOption() $this->assertStringContainsString('getDisplay(), '->execute() returns an XML help text if --format=xml is passed'); } - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions) { require_once realpath(__DIR__.'/../Fixtures/FooCommand.php'); diff --git a/src/Symfony/Component/Console/Tests/Command/InvokableCommandTest.php b/src/Symfony/Component/Console/Tests/Command/InvokableCommandTest.php index 8bd0dceb4425e..1eac2994485f1 100644 --- a/src/Symfony/Component/Console/Tests/Command/InvokableCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/InvokableCommandTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Console\Tests\Command; use PHPUnit\Framework\Assert; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\Option; @@ -292,9 +293,7 @@ public function __invoke() $command->run(new ArrayInput([]), new NullOutput()); } - /** - * @dataProvider provideInputArguments - */ + #[DataProvider('provideInputArguments')] public function testInputArguments(array $parameters, array $expected) { $command = new Command('foo'); @@ -322,9 +321,7 @@ public static function provideInputArguments(): \Generator yield 'required & without-value' => [['a' => 'x', 'b' => null, 'c' => null, 'd' => null], ['x', null, '', []]]; } - /** - * @dataProvider provideBinaryInputOptions - */ + #[DataProvider('provideBinaryInputOptions')] public function testBinaryInputOptions(array $parameters, array $expected) { $command = new Command('foo'); @@ -350,9 +347,7 @@ public static function provideBinaryInputOptions(): \Generator yield 'negative' => [['--no-a' => null, '--no-c' => null], [false, false, false]]; } - /** - * @dataProvider provideNonBinaryInputOptions - */ + #[DataProvider('provideNonBinaryInputOptions')] public function testNonBinaryInputOptions(array $parameters, array $expected) { $command = new Command('foo'); @@ -405,9 +400,7 @@ public static function provideNonBinaryInputOptions(): \Generator ]; } - /** - * @dataProvider provideInvalidOptionDefinitions - */ + #[DataProvider('provideInvalidOptionDefinitions')] public function testInvalidOptionDefinition(callable $code) { $command = new Command('foo'); diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index 37496c6b33bb2..7efdb5ab50485 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Command; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandCompletionTester; @@ -115,9 +116,7 @@ public function testExecuteListsCommandsOrderRaw() $this->assertEquals($output, trim($commandTester->getDisplay(true))); } - /** - * @dataProvider provideCompletionSuggestions - */ + #[DataProvider('provideCompletionSuggestions')] public function testComplete(array $input, array $expectedSuggestions) { require_once realpath(__DIR__.'/../Fixtures/FooCommand.php'); diff --git a/src/Symfony/Component/Console/Tests/Completion/CompletionInputTest.php b/src/Symfony/Component/Console/Tests/Completion/CompletionInputTest.php index df0d081fd9acb..58493fdf00fec 100644 --- a/src/Symfony/Component/Console/Tests/Completion/CompletionInputTest.php +++ b/src/Symfony/Component/Console/Tests/Completion/CompletionInputTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Completion; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Completion\CompletionInput; use Symfony\Component\Console\Input\InputArgument; @@ -19,9 +20,7 @@ class CompletionInputTest extends TestCase { - /** - * @dataProvider provideBindData - */ + #[DataProvider('provideBindData')] public function testBind(CompletionInput $input, string $expectedType, ?string $expectedName, string $expectedValue) { $definition = new InputDefinition([ @@ -74,9 +73,7 @@ public static function provideBindData() yield 'end' => [CompletionInput::fromTokens(['bin/console', 'symfony', 'sensiolabs'], 3), CompletionInput::TYPE_NONE, null, '']; } - /** - * @dataProvider provideBindWithLastArrayArgumentData - */ + #[DataProvider('provideBindWithLastArrayArgumentData')] public function testBindWithLastArrayArgument(CompletionInput $input, ?string $expectedValue) { $definition = new InputDefinition([ @@ -111,9 +108,7 @@ public function testBindArgumentWithDefault() $this->assertEquals('', $input->getCompletionValue(), 'Unexpected value'); } - /** - * @dataProvider provideFromStringData - */ + #[DataProvider('provideFromStringData')] public function testFromString($inputStr, array $expectedTokens) { $input = CompletionInput::fromString($inputStr, 1); diff --git a/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php b/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php index a11e6b5109acb..953e5843c24b8 100644 --- a/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php +++ b/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\DependencyInjection; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; @@ -28,9 +29,7 @@ class AddConsoleCommandPassTest extends TestCase { - /** - * @dataProvider visibilityProvider - */ + #[DataProvider('visibilityProvider')] public function testProcess($public) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php b/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php index 93658f4beca4d..0c4eee158d433 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTestCase.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Descriptor; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; @@ -21,31 +22,31 @@ abstract class AbstractDescriptorTestCase extends TestCase { - /** @dataProvider getDescribeInputArgumentTestData */ + #[DataProvider('getDescribeInputArgumentTestData')] public function testDescribeInputArgument(InputArgument $argument, $expectedDescription) { $this->assertDescription($expectedDescription, $argument); } - /** @dataProvider getDescribeInputOptionTestData */ + #[DataProvider('getDescribeInputOptionTestData')] public function testDescribeInputOption(InputOption $option, $expectedDescription) { $this->assertDescription($expectedDescription, $option); } - /** @dataProvider getDescribeInputDefinitionTestData */ + #[DataProvider('getDescribeInputDefinitionTestData')] public function testDescribeInputDefinition(InputDefinition $definition, $expectedDescription) { $this->assertDescription($expectedDescription, $definition); } - /** @dataProvider getDescribeCommandTestData */ + #[DataProvider('getDescribeCommandTestData')] public function testDescribeCommand(Command $command, $expectedDescription) { $this->assertDescription($expectedDescription, $command); } - /** @dataProvider getDescribeApplicationTestData */ + #[DataProvider('getDescribeApplicationTestData')] public function testDescribeApplication(Application $application, $expectedDescription) { // the "completion" command has dynamic help information depending on the shell diff --git a/src/Symfony/Component/Console/Tests/Descriptor/ApplicationDescriptionTest.php b/src/Symfony/Component/Console/Tests/Descriptor/ApplicationDescriptionTest.php index ab90320cd6846..a6117952a2023 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/ApplicationDescriptionTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/ApplicationDescriptionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Descriptor; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; @@ -18,9 +19,7 @@ final class ApplicationDescriptionTest extends TestCase { - /** - * @dataProvider getNamespacesProvider - */ + #[DataProvider('getNamespacesProvider')] public function testGetNamespaces(array $expected, array $names) { $application = new TestApplication(); diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php index b66b6abe487a2..2ffe7b301f665 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Formatter; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Formatter\OutputFormatterStyle; @@ -159,9 +160,7 @@ public function testInlineStyle() $this->assertEquals("\033[34;41msome text\033[39;49m", $formatter->format('some text')); } - /** - * @dataProvider provideInlineStyleOptionsCases - */ + #[DataProvider('provideInlineStyleOptionsCases')] public function testInlineStyleOptions(string $tag, ?string $expected = null, ?string $input = null, bool $truecolor = false) { if ($truecolor && 'truecolor' !== getenv('COLORTERM')) { @@ -177,7 +176,7 @@ public function testInlineStyleOptions(string $tag, ?string $expected = null, ?s $expected = $tag.$input.''; $this->assertSame($expected, $formatter->format($expected)); } else { - /** @var OutputFormatterStyle $result */ + /* @var OutputFormatterStyle $result */ $this->assertInstanceOf(OutputFormatterStyle::class, $result); $this->assertSame($expected, $formatter->format($tag.$input.'')); $this->assertSame($expected, $formatter->format($tag.$input.'')); @@ -241,9 +240,7 @@ public function testFormatterHasStyles() $this->assertTrue($formatter->hasStyle('question')); } - /** - * @dataProvider provideDecoratedAndNonDecoratedOutput - */ + #[DataProvider('provideDecoratedAndNonDecoratedOutput')] public function testNotDecoratedFormatterOnJediTermEmulator(string $input, string $expectedNonDecoratedOutput, string $expectedDecoratedOutput, bool $shouldBeJediTerm = false) { $terminalEmulator = $shouldBeJediTerm ? 'JetBrains-JediTerm' : 'Unknown'; @@ -259,9 +256,7 @@ public function testNotDecoratedFormatterOnJediTermEmulator(string $input, strin } } - /** - * @dataProvider provideDecoratedAndNonDecoratedOutput - */ + #[DataProvider('provideDecoratedAndNonDecoratedOutput')] public function testNotDecoratedFormatterOnIDEALikeEnvironment(string $input, string $expectedNonDecoratedOutput, string $expectedDecoratedOutput, bool $expectsIDEALikeTerminal = false) { // Backup previous env variable diff --git a/src/Symfony/Component/Console/Tests/Helper/DumperNativeFallbackTest.php b/src/Symfony/Component/Console/Tests/Helper/DumperNativeFallbackTest.php index 1b37e4e9390c0..892590dd75fab 100644 --- a/src/Symfony/Component/Console/Tests/Helper/DumperNativeFallbackTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/DumperNativeFallbackTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Helper; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ClassExistsMock; use Symfony\Component\Console\Helper\Dumper; @@ -32,9 +33,7 @@ public static function tearDownAfterClass(): void ClassExistsMock::withMockedClasses([]); } - /** - * @dataProvider provideVariables - */ + #[DataProvider('provideVariables')] public function testInvoke($variable, $primitiveString) { $dumper = new Dumper($this->createMock(OutputInterface::class)); diff --git a/src/Symfony/Component/Console/Tests/Helper/DumperTest.php b/src/Symfony/Component/Console/Tests/Helper/DumperTest.php index 0a30c6ec34642..344d3f4dc7366 100644 --- a/src/Symfony/Component/Console/Tests/Helper/DumperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/DumperTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Helper; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Helper\Dumper; use Symfony\Component\Console\Output\OutputInterface; @@ -32,9 +33,7 @@ public static function tearDownAfterClass(): void putenv('DUMP_COMMA_SEPARATOR'); } - /** - * @dataProvider provideVariables - */ + #[DataProvider('provideVariables')] public function testInvoke($variable) { $output = $this->createMock(OutputInterface::class); diff --git a/src/Symfony/Component/Console/Tests/Helper/HelperTest.php b/src/Symfony/Component/Console/Tests/Helper/HelperTest.php index 009864454c671..95d5ee5d37def 100644 --- a/src/Symfony/Component/Console/Tests/Helper/HelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/HelperTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Helper; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Helper\Helper; @@ -61,17 +62,13 @@ public static function decoratedTextProvider() ]; } - /** - * @dataProvider formatTimeProvider - */ + #[DataProvider('formatTimeProvider')] public function testFormatTime(int|float $secs, string $expectedFormat, int $precision) { $this->assertEquals($expectedFormat, Helper::formatTime($secs, $precision)); } - /** - * @dataProvider decoratedTextProvider - */ + #[DataProvider('decoratedTextProvider')] public function testRemoveDecoration(string $decoratedText, string $undecoratedText) { $this->assertEquals($undecoratedText, Helper::removeDecoration(new OutputFormatter(), $decoratedText)); diff --git a/src/Symfony/Component/Console/Tests/Helper/OutputWrapperTest.php b/src/Symfony/Component/Console/Tests/Helper/OutputWrapperTest.php index 2ce15b6d49b55..d09fd9ea908fa 100644 --- a/src/Symfony/Component/Console/Tests/Helper/OutputWrapperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/OutputWrapperTest.php @@ -11,14 +11,13 @@ namespace Symfony\Component\Console\Tests\Helper; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Helper\OutputWrapper; class OutputWrapperTest extends TestCase { - /** - * @dataProvider textProvider - */ + #[DataProvider('textProvider')] public function testBasicWrap(string $text, int $width, bool $allowCutUrls, string $expected) { $wrapper = new OutputWrapper($allowCutUrls); diff --git a/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php index 1fd88987baabe..02d9fb93961e8 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Helper; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Helper\DebugFormatterHelper; use Symfony\Component\Console\Helper\HelperSet; @@ -20,9 +21,7 @@ class ProcessHelperTest extends TestCase { - /** - * @dataProvider provideCommandsAndOutput - */ + #[DataProvider('provideCommandsAndOutput')] public function testVariousProcessRuns(string $expected, Process|string|array $cmd, int $verbosity, ?string $error) { if (\is_string($cmd)) { diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php index c0278cc330462..683bc7c871674 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Console\Tests\Helper; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Helper\Helper; @@ -18,9 +20,7 @@ use Symfony\Component\Console\Output\ConsoleSectionOutput; use Symfony\Component\Console\Output\StreamOutput; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class ProgressBarTest extends TestCase { private string|false $colSize; @@ -1117,9 +1117,7 @@ public function testUnicode() $bar->finish(); } - /** - * @dataProvider provideFormat - */ + #[DataProvider('provideFormat')] public function testFormatsWithoutMax($format) { $bar = new ProgressBar($output = $this->getOutputStream(), 0, 0); diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php index 2a4441d571cfc..fb11d14324af4 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php @@ -11,13 +11,13 @@ namespace Symfony\Component\Console\Tests\Helper; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Helper\ProgressIndicator; use Symfony\Component\Console\Output\StreamOutput; -/** - * @group time-sensitive - */ +#[Group('time-sensitive')] class ProgressIndicatorTest extends TestCase { public function testDefaultIndicator() @@ -176,9 +176,7 @@ public function testCannotFinishUnstartedIndicator() $bar->finish('Finished'); } - /** - * @dataProvider provideFormat - */ + #[DataProvider('provideFormat')] public function testFormats($format) { $bar = new ProgressIndicator($output = $this->getOutputStream(), $format); diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index b6ecc5ed3a3ad..8ea4b1934bf97 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Console\Tests\Helper; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\Console\Application; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\MissingInputException; @@ -27,9 +29,7 @@ use Symfony\Component\Console\Terminal; use Symfony\Component\Console\Tester\ApplicationTester; -/** - * @group tty - */ +#[Group('tty')] class QuestionHelperTest extends AbstractQuestionHelperTestCase { public function testAskChoice() @@ -348,9 +348,7 @@ public static function getInputs() ]; } - /** - * @dataProvider getInputs - */ + #[DataProvider('getInputs')] public function testAskWithAutocompleteWithMultiByteCharacter($character) { if (!Terminal::hasSttyAvailable()) { @@ -522,9 +520,7 @@ public function testAskMultilineResponseWithWithCursorInMiddleOfSeekableInputStr $this->assertSame(8, ftell($response)); } - /** - * @dataProvider getAskConfirmationData - */ + #[DataProvider('getAskConfirmationData')] public function testAskConfirmation($question, $expected, $default = true) { $dialog = new QuestionHelper(); @@ -588,9 +584,7 @@ public function testAskAndValidate() } } - /** - * @dataProvider simpleAnswerProvider - */ + #[DataProvider('simpleAnswerProvider')] public function testSelectChoiceFromSimpleChoices($providedAnswer, $expectedValue) { $possibleChoices = [ @@ -622,9 +616,7 @@ public static function simpleAnswerProvider() ]; } - /** - * @dataProvider specialCharacterInMultipleChoice - */ + #[DataProvider('specialCharacterInMultipleChoice')] public function testSpecialCharacterChoiceFromMultipleChoiceList($providedAnswer, $expectedValue) { $possibleChoices = [ @@ -653,9 +645,7 @@ public static function specialCharacterInMultipleChoice() ]; } - /** - * @dataProvider answerProvider - */ + #[DataProvider('answerProvider')] public function testSelectChoiceFromChoiceList($providedAnswer, $expectedValue) { $possibleChoices = [ diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php index 6cf79965bba7e..56b8f210d5f58 100644 --- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Helper; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\Console\Exception\RuntimeException; use Symfony\Component\Console\Helper\FormatterHelper; use Symfony\Component\Console\Helper\HelperSet; @@ -20,9 +21,7 @@ use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\Question; -/** - * @group tty - */ +#[Group('tty')] class SymfonyQuestionHelperTest extends AbstractQuestionHelperTestCase { public function testAskChoice() diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index eb85364dae5fb..4ab606b549695 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Helper; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\RuntimeException; @@ -38,9 +39,7 @@ protected function tearDown(): void unset($this->stream); } - /** - * @dataProvider renderProvider - */ + #[DataProvider('renderProvider')] public function testRender($headers, $rows, $style, $expected, $decorated = false) { $table = new Table($output = $this->getOutputStream($decorated)); @@ -54,9 +53,7 @@ public function testRender($headers, $rows, $style, $expected, $decorated = fals $this->assertEquals($expected, $this->getOutputContent($output)); } - /** - * @dataProvider renderProvider - */ + #[DataProvider('renderProvider')] public function testRenderAddRows($headers, $rows, $style, $expected, $decorated = false) { $table = new Table($output = $this->getOutputStream($decorated)); @@ -70,9 +67,7 @@ public function testRenderAddRows($headers, $rows, $style, $expected, $decorated $this->assertEquals($expected, $this->getOutputContent($output)); } - /** - * @dataProvider renderProvider - */ + #[DataProvider('renderProvider')] public function testRenderAddRowsOneByOne($headers, $rows, $style, $expected, $decorated = false) { $table = new Table($output = $this->getOutputStream($decorated)); @@ -1260,9 +1255,7 @@ public function testGetStyleDefinition() Table::getStyleDefinition('absent'); } - /** - * @dataProvider renderSetTitle - */ + #[DataProvider('renderSetTitle')] public function testSetTitle($headerTitle, $footerTitle, $style, $expected) { (new Table($output = $this->getOutputStream())) @@ -1536,9 +1529,7 @@ public static function provideRenderHorizontalTests() yield [$headers, $rows, $expected]; } - /** - * @dataProvider provideRenderHorizontalTests - */ + #[DataProvider('provideRenderHorizontalTests')] public function testRenderHorizontal(array $headers, array $rows, string $expected) { $table = new Table($output = $this->getOutputStream()); @@ -1984,9 +1975,7 @@ public static function provideRenderVerticalTests(): \Traversable ]; } - /** - * @dataProvider provideRenderVerticalTests - */ + #[DataProvider('provideRenderVerticalTests')] public function testVerticalRender(string $expectedOutput, array $headers, array $rows, string $style = 'default', string $headerTitle = '', string $footerTitle = '') { $table = new Table($output = $this->getOutputStream()); diff --git a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php index 0e76f9ee6db2a..dead40f460c30 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Input; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\InputArgument; @@ -39,9 +40,7 @@ public function testParseArguments() $this->assertSame(['name' => 'foo'], $input->getArguments(), '->parse() is stateless'); } - /** - * @dataProvider provideOptions - */ + #[DataProvider('provideOptions')] public function testParseOptions($input, $options, $expectedOptions, $message) { $input = new ArgvInput($input); @@ -50,9 +49,7 @@ public function testParseOptions($input, $options, $expectedOptions, $message) $this->assertSame($expectedOptions, $input->getOptions(), $message); } - /** - * @dataProvider provideNegatableOptions - */ + #[DataProvider('provideNegatableOptions')] public function testParseOptionsNegatable($input, $options, $expectedOptions, $message) { $input = new ArgvInput($input); @@ -234,9 +231,7 @@ public static function provideNegatableOptions() ]; } - /** - * @dataProvider provideInvalidInput - */ + #[DataProvider('provideInvalidInput')] public function testInvalidInput($argv, $definition, $expectedExceptionMessage) { $this->expectException(\RuntimeException::class); @@ -245,9 +240,7 @@ public function testInvalidInput($argv, $definition, $expectedExceptionMessage) (new ArgvInput($argv))->bind($definition); } - /** - * @dataProvider provideInvalidNegatableInput - */ + #[DataProvider('provideInvalidNegatableInput')] public function testInvalidInputNegatable($argv, $definition, $expectedExceptionMessage) { $this->expectException(\RuntimeException::class); @@ -509,9 +502,7 @@ public function testToString() $this->assertSame('-f --bar=foo '.escapeshellarg('a b c d').' '.escapeshellarg("A\nB'C"), (string) $input); } - /** - * @dataProvider provideGetParameterOptionValues - */ + #[DataProvider('provideGetParameterOptionValues')] public function testGetParameterOptionEqualSign($argv, $key, $default, $onlyParams, $expected) { $input = new ArgvInput($argv); @@ -574,9 +565,7 @@ public function testGetRawTokensFalse() $this->assertSame(['--foo', 'bar'], $input->getRawTokens()); } - /** - * @dataProvider provideGetRawTokensTrueTests - */ + #[DataProvider('provideGetRawTokensTrueTests')] public function testGetRawTokensTrue(array $argv, array $expected) { $input = new ArgvInput($argv); diff --git a/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php index 74d2c089fb7b8..96bd08b8717b9 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Input; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; @@ -64,9 +65,7 @@ public function testParseArguments() $this->assertSame(['name' => 'foo'], $input->getArguments(), '->parse() parses required arguments'); } - /** - * @dataProvider provideOptions - */ + #[DataProvider('provideOptions')] public function testParseOptions($input, $options, $expectedOptions, $message) { $input = new ArrayInput($input, new InputDefinition($options)); @@ -122,9 +121,7 @@ public static function provideOptions(): array ]; } - /** - * @dataProvider provideInvalidInput - */ + #[DataProvider('provideInvalidInput')] public function testParseInvalidInput($parameters, $definition, $expectedExceptionMessage) { $this->expectException(\InvalidArgumentException::class); diff --git a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php index ab203e6e579c7..3925ec8e5953a 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Input; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; @@ -359,9 +360,7 @@ public function testGetOptionDefaults() $this->assertSame($defaults, $definition->getOptionDefaults(), '->getOptionDefaults() returns the default values for all options'); } - /** - * @dataProvider getGetSynopsisData - */ + #[DataProvider('getGetSynopsisData')] public function testGetSynopsis(InputDefinition $definition, $expectedSynopsis, $message = null) { $this->assertSame($expectedSynopsis, $definition->getSynopsis(), $message ? '->getSynopsis() '.$message : ''); diff --git a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php index 92425daab75ab..3a97938a28ff4 100644 --- a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Input; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\InputDefinition; @@ -19,9 +20,7 @@ class StringInputTest extends TestCase { - /** - * @dataProvider getTokenizeData - */ + #[DataProvider('getTokenizeData')] public function testTokenize($input, $tokens, $message) { $input = new StringInput($input); diff --git a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php index 0464c8c5fad49..976ff7a980ea5 100644 --- a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php +++ b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Logger; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Log\InvalidArgumentException; use Psr\Log\LoggerInterface; @@ -54,9 +55,7 @@ public function getLogs(): array return $this->output->getLogs(); } - /** - * @dataProvider provideOutputMappingParams - */ + #[DataProvider('provideOutputMappingParams')] public function testOutputMapping($logLevel, $outputVerbosity, $isOutput, $addVerbosityLevelMap = []) { $out = new BufferedOutput($outputVerbosity); @@ -104,9 +103,7 @@ public function testImplements() $this->assertInstanceOf(LoggerInterface::class, $this->getLogger()); } - /** - * @dataProvider provideLevelsAndMessages - */ + #[DataProvider('provideLevelsAndMessages')] public function testLogsAtAllLevels($level, $message) { $logger = $this->getLogger(); diff --git a/src/Symfony/Component/Console/Tests/Output/AnsiColorModeTest.php b/src/Symfony/Component/Console/Tests/Output/AnsiColorModeTest.php index eb3e463e8e504..aa1506e26ac0c 100644 --- a/src/Symfony/Component/Console/Tests/Output/AnsiColorModeTest.php +++ b/src/Symfony/Component/Console/Tests/Output/AnsiColorModeTest.php @@ -11,23 +11,20 @@ namespace Symfony\Component\Console\Tests\Output; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Output\AnsiColorMode; class AnsiColorModeTest extends TestCase { - /** - * @dataProvider provideColorsConversion - */ + #[DataProvider('provideColorsConversion')] public function testColorsConversionToAnsi4(string $corlorHex, array $expected) { $this->assertSame((string) $expected[AnsiColorMode::Ansi4->name], AnsiColorMode::Ansi4->convertFromHexToAnsiColorCode($corlorHex)); } - /** - * @dataProvider provideColorsConversion - */ + #[DataProvider('provideColorsConversion')] public function testColorsConversionToAnsi8(string $corlorHex, array $expected) { $this->assertSame('8;5;'.$expected[AnsiColorMode::Ansi8->name], AnsiColorMode::Ansi8->convertFromHexToAnsiColorCode($corlorHex)); diff --git a/src/Symfony/Component/Console/Tests/Output/OutputTest.php b/src/Symfony/Component/Console/Tests/Output/OutputTest.php index 64e4910484188..cd3f09680b3dd 100644 --- a/src/Symfony/Component/Console/Tests/Output/OutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/OutputTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Output; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Output\Output; @@ -94,9 +95,7 @@ private function generateMessages(): iterable yield 'bar'; } - /** - * @dataProvider provideWriteArguments - */ + #[DataProvider('provideWriteArguments')] public function testWriteRawMessage($message, $type, $expectedOutput) { $output = new TestOutput(); @@ -143,9 +142,7 @@ public function testWriteWithInvalidStyle() $this->assertEquals("foo\n", $output->output, '->writeln() do nothing when a style does not exist'); } - /** - * @dataProvider verbosityProvider - */ + #[DataProvider('verbosityProvider')] public function testWriteWithVerbosityOption($verbosity, $expected, $msg) { $output = new TestOutput(); diff --git a/src/Symfony/Component/Console/Tests/Question/ChoiceQuestionTest.php b/src/Symfony/Component/Console/Tests/Question/ChoiceQuestionTest.php index 564dee7240a2c..613cb621f5b70 100644 --- a/src/Symfony/Component/Console/Tests/Question/ChoiceQuestionTest.php +++ b/src/Symfony/Component/Console/Tests/Question/ChoiceQuestionTest.php @@ -11,14 +11,13 @@ namespace Symfony\Component\Console\Tests\Question; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Question\ChoiceQuestion; class ChoiceQuestionTest extends TestCase { - /** - * @dataProvider selectUseCases - */ + #[DataProvider('selectUseCases')] public function testSelectUseCases($multiSelect, $answers, $expected, $message, $default = null) { $question = new ChoiceQuestion('A question', [ @@ -104,9 +103,7 @@ public function testNonTrimmable() $this->assertSame(['First response ', ' Second response'], $question->getValidator()('First response , Second response')); } - /** - * @dataProvider selectAssociativeChoicesProvider - */ + #[DataProvider('selectAssociativeChoicesProvider')] public function testSelectAssociativeChoices($providedAnswer, $expectedValue) { $question = new ChoiceQuestion('A question', [ diff --git a/src/Symfony/Component/Console/Tests/Question/ConfirmationQuestionTest.php b/src/Symfony/Component/Console/Tests/Question/ConfirmationQuestionTest.php index bd11047b39065..4e3d99fea284d 100644 --- a/src/Symfony/Component/Console/Tests/Question/ConfirmationQuestionTest.php +++ b/src/Symfony/Component/Console/Tests/Question/ConfirmationQuestionTest.php @@ -11,14 +11,13 @@ namespace Symfony\Component\Console\Tests\Question; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Question\ConfirmationQuestion; class ConfirmationQuestionTest extends TestCase { - /** - * @dataProvider normalizerUsecases - */ + #[DataProvider('normalizerUsecases')] public function testDefaultRegexUsecases($default, $answers, $expected, $message) { $sut = new ConfirmationQuestion('A question', $default); diff --git a/src/Symfony/Component/Console/Tests/Question/QuestionTest.php b/src/Symfony/Component/Console/Tests/Question/QuestionTest.php index 15d8212b95498..0fc26aed128f6 100644 --- a/src/Symfony/Component/Console/Tests/Question/QuestionTest.php +++ b/src/Symfony/Component/Console/Tests/Question/QuestionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Question; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Question\Question; @@ -44,9 +45,7 @@ public function testGetDefaultDefault() self::assertNull($this->question->getDefault()); } - /** - * @dataProvider providerTrueFalse - */ + #[DataProvider('providerTrueFalse')] public function testIsSetHidden(bool $hidden) { $this->question->setHidden($hidden); @@ -89,9 +88,7 @@ public function testSetHiddenWithNoAutocompleterCallback() $this->assertNull($exception); } - /** - * @dataProvider providerTrueFalse - */ + #[DataProvider('providerTrueFalse')] public function testIsSetHiddenFallback(bool $hidden) { $this->question->setHiddenFallback($hidden); @@ -122,9 +119,7 @@ public static function providerGetSetAutocompleterValues() ]; } - /** - * @dataProvider providerGetSetAutocompleterValues - */ + #[DataProvider('providerGetSetAutocompleterValues')] public function testGetSetAutocompleterValues($values, $expectValues) { $this->question->setAutocompleterValues($values); @@ -143,9 +138,7 @@ public static function providerSetAutocompleterValuesInvalid() ]; } - /** - * @dataProvider providerSetAutocompleterValuesInvalid - */ + #[DataProvider('providerSetAutocompleterValuesInvalid')] public function testSetAutocompleterValuesInvalid($values) { self::expectException(\TypeError::class); @@ -236,9 +229,7 @@ public static function providerGetSetValidator() ]; } - /** - * @dataProvider providerGetSetValidator - */ + #[DataProvider('providerGetSetValidator')] public function testGetSetValidator($callback) { $this->question->setValidator($callback); @@ -255,9 +246,7 @@ public static function providerGetSetMaxAttempts() return [[1], [5], [null]]; } - /** - * @dataProvider providerGetSetMaxAttempts - */ + #[DataProvider('providerGetSetMaxAttempts')] public function testGetSetMaxAttempts($attempts) { $this->question->setMaxAttempts($attempts); @@ -269,9 +258,7 @@ public static function providerSetMaxAttemptsInvalid() return [[0], [-1]]; } - /** - * @dataProvider providerSetMaxAttemptsInvalid - */ + #[DataProvider('providerSetMaxAttemptsInvalid')] public function testSetMaxAttemptsInvalid($attempts) { self::expectException(\InvalidArgumentException::class); @@ -297,9 +284,7 @@ public function testGetNormalizerDefault() self::assertNull($this->question->getNormalizer()); } - /** - * @dataProvider providerTrueFalse - */ + #[DataProvider('providerTrueFalse')] public function testSetMultiline(bool $multiline) { self::assertSame($this->question, $this->question->setMultiline($multiline)); diff --git a/src/Symfony/Component/Console/Tests/SignalRegistry/SignalMapTest.php b/src/Symfony/Component/Console/Tests/SignalRegistry/SignalMapTest.php index 3a0c49bb01e21..9bc7f34a2696f 100644 --- a/src/Symfony/Component/Console/Tests/SignalRegistry/SignalMapTest.php +++ b/src/Symfony/Component/Console/Tests/SignalRegistry/SignalMapTest.php @@ -11,14 +11,13 @@ namespace Symfony\Component\Console\Tests\SignalRegistry; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\SignalRegistry\SignalMap; class SignalMapTest extends TestCase { - /** - * @requires extension pcntl - */ + #[RequiresPhpExtension('pcntl')] public function testSignalExists() { $this->assertSame('SIGINT', SignalMap::getSignalName(\SIGINT)); diff --git a/src/Symfony/Component/Console/Tests/SignalRegistry/SignalRegistryTest.php b/src/Symfony/Component/Console/Tests/SignalRegistry/SignalRegistryTest.php index 92d500f9ee4e5..51146b3f278cb 100644 --- a/src/Symfony/Component/Console/Tests/SignalRegistry/SignalRegistryTest.php +++ b/src/Symfony/Component/Console/Tests/SignalRegistry/SignalRegistryTest.php @@ -11,12 +11,11 @@ namespace Symfony\Component\Console\Tests\SignalRegistry; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\SignalRegistry\SignalRegistry; -/** - * @requires extension pcntl - */ +#[RequiresPhpExtension('pcntl')] class SignalRegistryTest extends TestCase { protected function tearDown(): void diff --git a/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php b/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php index a3b7ae406c236..8f82733e68ed3 100644 --- a/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php +++ b/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Style; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Exception\RuntimeException; @@ -47,9 +48,7 @@ protected function tearDown(): void putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS'); } - /** - * @dataProvider inputCommandToOutputFilesProvider - */ + #[DataProvider('inputCommandToOutputFilesProvider')] public function testOutputs($inputCommandFilepath, $outputFilepath) { $code = require $inputCommandFilepath; @@ -58,9 +57,7 @@ public function testOutputs($inputCommandFilepath, $outputFilepath) $this->assertStringEqualsFile($outputFilepath, $this->tester->getDisplay(true)); } - /** - * @dataProvider inputInteractiveCommandToOutputFilesProvider - */ + #[DataProvider('inputInteractiveCommandToOutputFilesProvider')] public function testInteractiveOutputs($inputCommandFilepath, $outputFilepath) { $code = require $inputCommandFilepath; diff --git a/src/Symfony/Component/Console/Tests/TerminalTest.php b/src/Symfony/Component/Console/Tests/TerminalTest.php index d43469d12bb1f..4d417dfba748b 100644 --- a/src/Symfony/Component/Console/Tests/TerminalTest.php +++ b/src/Symfony/Component/Console/Tests/TerminalTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Output\AnsiColorMode; use Symfony\Component\Console\Terminal; @@ -95,9 +96,7 @@ public function testSttyOnWindows() $this->assertSame((int) $matches[1], $terminal->getWidth()); } - /** - * @dataProvider provideTerminalColorEnv - */ + #[DataProvider('provideTerminalColorEnv')] public function testGetColorMode(?string $testColorTerm, ?string $testTerm, AnsiColorMode $expected) { $oriColorTerm = getenv('COLORTERM'); diff --git a/src/Symfony/Component/Console/Tests/Tester/Constraint/CommandIsSuccessfulTest.php b/src/Symfony/Component/Console/Tests/Tester/Constraint/CommandIsSuccessfulTest.php index 61ab5d0f8c998..415f3861faf4a 100644 --- a/src/Symfony/Component/Console/Tests/Tester/Constraint/CommandIsSuccessfulTest.php +++ b/src/Symfony/Component/Console/Tests/Tester/Constraint/CommandIsSuccessfulTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Tester\Constraint; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\ExpectationFailedException; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Command\Command; @@ -27,9 +28,7 @@ public function testConstraint() $this->assertFalse($constraint->evaluate(Command::INVALID, '', true)); } - /** - * @dataProvider providesUnsuccessful - */ + #[DataProvider('providesUnsuccessful')] public function testUnsuccessfulCommand(string $expectedException, int $exitCode) { $constraint = new CommandIsSuccessful(); diff --git a/src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php b/src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php index c197032e5a817..1d4dbb7ad6ea9 100644 --- a/src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php +++ b/src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\CssSelector\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\CssSelector\CssSelectorConverter; use Symfony\Component\CssSelector\Exception\ParseException; @@ -51,7 +52,7 @@ public function testParseExceptions() (new CssSelectorConverter())->toXPath('h1:'); } - /** @dataProvider getCssToXPathWithoutPrefixTestData */ + #[DataProvider('getCssToXPathWithoutPrefixTestData')] public function testCssToXPathWithoutPrefix($css, $xpath) { $converter = new CssSelectorConverter(); diff --git a/src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php b/src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php index 521e6d8bce7ce..64553bfbf2ee1 100644 --- a/src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php +++ b/src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php @@ -11,18 +11,19 @@ namespace Symfony\Component\CssSelector\Tests\Node; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\CssSelector\Node\NodeInterface; abstract class AbstractNodeTestCase extends TestCase { - /** @dataProvider getToStringConversionTestData */ + #[DataProvider('getToStringConversionTestData')] public function testToStringConversion(NodeInterface $node, $representation) { $this->assertEquals($representation, (string) $node); } - /** @dataProvider getSpecificityValueTestData */ + #[DataProvider('getSpecificityValueTestData')] public function testSpecificityValue(NodeInterface $node, $value) { $this->assertEquals($value, $node->getSpecificity()->getValue()); diff --git a/src/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php b/src/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php index 8802e0c40ee1b..ae765898a6a52 100644 --- a/src/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php @@ -11,18 +11,19 @@ namespace Symfony\Component\CssSelector\Tests\Node; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\CssSelector\Node\Specificity; class SpecificityTest extends TestCase { - /** @dataProvider getValueTestData */ + #[DataProvider('getValueTestData')] public function testValue(Specificity $specificity, $value) { $this->assertEquals($value, $specificity->getValue()); } - /** @dataProvider getValueTestData */ + #[DataProvider('getValueTestData')] public function testPlusValue(Specificity $specificity, $value) { $this->assertEquals($value + 123, $specificity->plus(new Specificity(1, 2, 3))->getValue()); @@ -39,7 +40,7 @@ public static function getValueTestData() ]; } - /** @dataProvider getCompareTestData */ + #[DataProvider('getCompareTestData')] public function testCompareTo(Specificity $a, Specificity $b, $result) { $this->assertEquals($result, $a->compareTo($b)); diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php index 30ce10e42fc82..65754daac4961 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php @@ -11,6 +11,7 @@ namespace Symfony\Component\CssSelector\Tests\Parser\Handler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\CssSelector\Parser\Reader; use Symfony\Component\CssSelector\Parser\Token; @@ -21,7 +22,7 @@ */ abstract class AbstractHandlerTestCase extends TestCase { - /** @dataProvider getHandleValueTestData */ + #[DataProvider('getHandleValueTestData')] public function testHandleValue($value, Token $expectedToken, $remainingContent) { $reader = new Reader($value); @@ -32,7 +33,7 @@ public function testHandleValue($value, Token $expectedToken, $remainingContent) $this->assertRemainingContent($reader, $remainingContent); } - /** @dataProvider getDontHandleValueTestData */ + #[DataProvider('getDontHandleValueTestData')] public function testDontHandleValue($value) { $reader = new Reader($value); diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php index c3be7f486b0d3..77058177db372 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\CssSelector\Tests\Parser\Handler; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\CssSelector\Parser\Handler\CommentHandler; use Symfony\Component\CssSelector\Parser\Reader; use Symfony\Component\CssSelector\Parser\Token; @@ -18,7 +19,7 @@ class CommentHandlerTest extends AbstractHandlerTestCase { - /** @dataProvider getHandleValueTestData */ + #[DataProvider('getHandleValueTestData')] public function testHandleValue($value, Token $unusedArgument, $remainingContent) { $reader = new Reader($value); diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php index 82de5ab6b8562..15b8a1b338a17 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\CssSelector\Tests\Parser; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\CssSelector\Exception\SyntaxErrorException; use Symfony\Component\CssSelector\Node\FunctionNode; @@ -20,7 +21,7 @@ class ParserTest extends TestCase { - /** @dataProvider getParserTestData */ + #[DataProvider('getParserTestData')] public function testParser($source, $representation) { $parser = new Parser(); @@ -28,7 +29,7 @@ public function testParser($source, $representation) $this->assertEquals($representation, array_map(fn (SelectorNode $node) => (string) $node->getTree(), $parser->parse($source))); } - /** @dataProvider getParserExceptionTestData */ + #[DataProvider('getParserExceptionTestData')] public function testParserException($source, $message) { $parser = new Parser(); @@ -41,7 +42,7 @@ public function testParserException($source, $message) } } - /** @dataProvider getPseudoElementsTestData */ + #[DataProvider('getPseudoElementsTestData')] public function testPseudoElements($source, $element, $pseudo) { $parser = new Parser(); @@ -54,7 +55,7 @@ public function testPseudoElements($source, $element, $pseudo) $this->assertEquals($pseudo, (string) $selector->getPseudoElement()); } - /** @dataProvider getSpecificityTestData */ + #[DataProvider('getSpecificityTestData')] public function testSpecificity($source, $value) { $parser = new Parser(); @@ -66,7 +67,7 @@ public function testSpecificity($source, $value) $this->assertEquals($value, $selector->getSpecificity()->getValue()); } - /** @dataProvider getParseSeriesTestData */ + #[DataProvider('getParseSeriesTestData')] public function testParseSeries($series, $a, $b) { $parser = new Parser(); @@ -78,7 +79,7 @@ public function testParseSeries($series, $a, $b) $this->assertEquals([$a, $b], Parser::parseSeries($function->getArguments())); } - /** @dataProvider getParseSeriesExceptionTestData */ + #[DataProvider('getParseSeriesExceptionTestData')] public function testParseSeriesException($series) { $parser = new Parser(); diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php index ded92ea3c2d20..c18b8101bc83a 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\CssSelector\Tests\Parser\Shortcut; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\CssSelector\Node\SelectorNode; use Symfony\Component\CssSelector\Parser\Shortcut\ClassParser; @@ -20,7 +21,7 @@ */ class ClassParserTest extends TestCase { - /** @dataProvider getParseTestData */ + #[DataProvider('getParseTestData')] public function testParse($source, $representation) { $parser = new ClassParser(); diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php index 4c1002959df1b..a4d1712c3fd15 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\CssSelector\Tests\Parser\Shortcut; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\CssSelector\Node\SelectorNode; use Symfony\Component\CssSelector\Parser\Shortcut\ElementParser; @@ -20,7 +21,7 @@ */ class ElementParserTest extends TestCase { - /** @dataProvider getParseTestData */ + #[DataProvider('getParseTestData')] public function testParse($source, $representation) { $parser = new ElementParser(); diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php index c8bfdef9f7369..d9225ce53417c 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\CssSelector\Tests\Parser\Shortcut; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\CssSelector\Node\SelectorNode; use Symfony\Component\CssSelector\Parser\Shortcut\HashParser; @@ -20,7 +21,7 @@ */ class HashParserTest extends TestCase { - /** @dataProvider getParseTestData */ + #[DataProvider('getParseTestData')] public function testParse($source, $representation) { $parser = new HashParser(); diff --git a/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php b/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php index f521a94708423..174f6b063ff45 100644 --- a/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php +++ b/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\CssSelector\Tests\XPath; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\CssSelector\Exception\ExpressionErrorException; use Symfony\Component\CssSelector\Node\ElementNode; @@ -22,13 +23,13 @@ class TranslatorTest extends TestCase { - /** @dataProvider getXpathLiteralTestData */ + #[DataProvider('getXpathLiteralTestData')] public function testXpathLiteral($value, $literal) { $this->assertEquals($literal, Translator::getXpathLiteral($value)); } - /** @dataProvider getCssToXPathTestData */ + #[DataProvider('getCssToXPathTestData')] public function testCssToXPath($css, $xpath) { $translator = new Translator(); @@ -103,7 +104,7 @@ public function testAddAttributeMatchingClassNotExistsClass() $translator->addAttributeMatching($xpath, '', '', ''); } - /** @dataProvider getXmlLangTestData */ + #[DataProvider('getXmlLangTestData')] public function testXmlLang($css, array $elementsId) { $translator = new Translator(); @@ -115,7 +116,7 @@ public function testXmlLang($css, array $elementsId) } } - /** @dataProvider getHtmlIdsTestData */ + #[DataProvider('getHtmlIdsTestData')] public function testHtmlIds($css, array $elementsId) { $translator = new Translator(); @@ -136,7 +137,7 @@ public function testHtmlIds($css, array $elementsId) libxml_use_internal_errors($internalErrors); } - /** @dataProvider getHtmlShakespearTestData */ + #[DataProvider('getHtmlShakespearTestData')] public function testHtmlShakespear($css, $count) { $translator = new Translator(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/AliasTest.php b/src/Symfony/Component/DependencyInjection/Tests/AliasTest.php index b1c8a4dbd8378..f4e2c4c992fe2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/AliasTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/AliasTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; @@ -69,9 +70,7 @@ public function testReturnsCorrectDeprecation() $this->assertEquals('1.1', $deprecation['version']); } - /** - * @dataProvider invalidDeprecationMessageProvider - */ + #[DataProvider('invalidDeprecationMessageProvider')] public function testCannotDeprecateWithAnInvalidTemplate($message) { $def = new Alias('foo'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Argument/TaggedIteratorArgumentTest.php b/src/Symfony/Component/DependencyInjection/Tests/Argument/TaggedIteratorArgumentTest.php index dcc38dde7fb19..df7d393c04e7a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Argument/TaggedIteratorArgumentTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Argument/TaggedIteratorArgumentTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Argument; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; @@ -57,9 +58,7 @@ public function testOnlyTagWithNeedsIndexesAndDotsTag() $this->assertSame('getDefaultQuxPriority', $taggedIteratorArgument->getDefaultPriorityMethod()); } - /** - * @dataProvider defaultIndexMethodProvider - */ + #[DataProvider('defaultIndexMethodProvider')] public function testDefaultIndexMethod(?string $indexAttribute, ?string $defaultIndexMethod, ?string $expectedDefaultIndexMethod) { $taggedIteratorArgument = new TaggedIteratorArgument('foo', $indexAttribute, $defaultIndexMethod); @@ -106,9 +105,7 @@ public static function defaultIndexMethodProvider() ]; } - /** - * @dataProvider defaultPriorityMethodProvider - */ + #[DataProvider('defaultPriorityMethodProvider')] public function testDefaultPriorityIndexMethod(?string $indexAttribute, ?string $defaultPriorityMethod, ?string $expectedDefaultPriorityMethod) { $taggedIteratorArgument = new TaggedIteratorArgument('foo', $indexAttribute, null, false, $defaultPriorityMethod); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Attribute/AutowireInlineTest.php b/src/Symfony/Component/DependencyInjection/Tests/Attribute/AutowireInlineTest.php index a9ae1fb252c66..26d2e7b13a2b3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Attribute/AutowireInlineTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Attribute/AutowireInlineTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Attribute; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Attribute\AutowireInline; use Symfony\Component\DependencyInjection\Reference; @@ -24,9 +25,7 @@ public function testInvalidFactoryArray() self::assertSame([123, 456], $autowireInline->value['factory']); } - /** - * @dataProvider provideInvalidCalls - */ + #[DataProvider('provideInvalidCalls')] public function testInvalidCallsArray(array $calls) { $autowireInline = new AutowireInline('someClass', calls: $calls); @@ -86,9 +85,7 @@ public function testClassAndParamsLazy() self::assertTrue($attribute->lazy); } - /** - * @dataProvider provideFactories - */ + #[DataProvider('provideFactories')] public function testFactory(string|array $factory, string|array $expectedResult) { $attribute = new AutowireInline($factory); @@ -101,9 +98,7 @@ public function testFactory(string|array $factory, string|array $expectedResult) self::assertFalse($attribute->lazy); } - /** - * @dataProvider provideFactories - */ + #[DataProvider('provideFactories')] public function testFactoryAndParams(string|array $factory, string|array $expectedResult) { $attribute = new AutowireInline($factory, ['someParam']); @@ -116,9 +111,7 @@ public function testFactoryAndParams(string|array $factory, string|array $expect self::assertFalse($attribute->lazy); } - /** - * @dataProvider provideFactories - */ + #[DataProvider('provideFactories')] public function testFactoryAndParamsLazy(string|array $factory, string|array $expectedResult) { $attribute = new AutowireInline($factory, ['someParam'], lazy: true); @@ -143,9 +136,7 @@ public static function provideFactories(): iterable yield '@reference with method' => [['@someClass', 'someMethod'], [new Reference('someClass'), 'someMethod']]; } - /** - * @dataProvider provideCalls - */ + #[DataProvider('provideCalls')] public function testCalls(string|array $calls, array $expectedResult) { $attribute = new AutowireInline('someClass', calls: $calls); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Attribute/AutowireTest.php b/src/Symfony/Component/DependencyInjection/Tests/Attribute/AutowireTest.php index aac42b0d2e363..6a3150c597c35 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Attribute/AutowireTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Attribute/AutowireTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Attribute; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\DependencyInjection\Exception\LogicException; @@ -19,9 +20,7 @@ class AutowireTest extends TestCase { - /** - * @dataProvider provideMultipleParameters - */ + #[DataProvider('provideMultipleParameters')] public function testCanOnlySetOneParameter(array $parameters) { $this->expectException(LogicException::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php index 39c96f8c55c5f..109d8a72045b2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ChildDefinition; @@ -24,9 +25,7 @@ public function testConstructor() $this->assertSame([], $def->getChanges()); } - /** - * @dataProvider getPropertyTests - */ + #[DataProvider('getPropertyTests')] public function testSetProperty($property, $changeKey) { $def = new ChildDefinition('foo'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AliasDeprecatedPublicServicesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AliasDeprecatedPublicServicesPassTest.php index df8f939f5c617..a720a0020ce0c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AliasDeprecatedPublicServicesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AliasDeprecatedPublicServicesPassTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Compiler\AliasDeprecatedPublicServicesPass; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -42,9 +43,7 @@ public function testProcess() ], $alias->getDeprecation('foo')); } - /** - * @dataProvider processWithMissingAttributeProvider - */ + #[DataProvider('processWithMissingAttributeProvider')] public function testProcessWithMissingAttribute(string $attribute, array $attributes) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index 20b97cad27909..9d51751b4c8b7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\TestCase; @@ -875,9 +876,7 @@ public function testWithFactory() $this->assertEquals([new TypedReference(Foo::class, Foo::class)], $definition->getArguments()); } - /** - * @dataProvider provideNotWireableCalls - */ + #[DataProvider('provideNotWireableCalls')] public function testNotWireableCalls($method, $expectedMsg) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php index 6d0a2edd083e5..d7d0f8e8a8a09 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Compiler\CheckArgumentsValidityPass; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -41,9 +42,7 @@ public function testProcess() ], $container->getDefinition('foo')->getMethodCalls()); } - /** - * @dataProvider definitionProvider - */ + #[DataProvider('definitionProvider')] public function testException(array $arguments, array $methodCalls) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php index df7dd03d02c27..bf32e4832e23e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Compiler\CheckDefinitionValidityPass; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -89,9 +90,7 @@ public function testValidTags() $this->addToAssertionCount(1); } - /** - * @dataProvider provideInvalidTags - */ + #[DataProvider('provideInvalidTags')] public function testInvalidTags(string $name, array $attributes, string $message) { $this->expectExceptionMessage($message); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php index 04a121d63dde2..73539acb5bd80 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Argument\BoundArgument; use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass; @@ -84,10 +85,8 @@ public function testProcessDefinitionWithBindings() $this->addToAssertionCount(1); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testWithErroredServiceLocator(bool $inline) { $container = new ContainerBuilder(); @@ -105,10 +104,8 @@ public function testWithErroredServiceLocator(bool $inline) $this->process($container); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testWithErroredHiddenService(bool $inline) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php index 3f185556540dc..bf61835f00f7e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Symfony\Component\Config\FileLocator; @@ -245,9 +246,7 @@ public function testAliasDecoratedService() $this->assertSame($container->get('service'), $container->get('decorator')); } - /** - * @dataProvider getYamlCompileTests - */ + #[DataProvider('getYamlCompileTests')] public function testYamlContainerCompiles($directory, $actualServiceId, $expectedServiceId, ?ContainerBuilder $mainContainer = null) { // allow a container to be passed in, which might have autoconfigure settings diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/PriorityTaggedServiceTraitTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/PriorityTaggedServiceTraitTest.php index 3f767257def91..fc0656b2e984b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/PriorityTaggedServiceTraitTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/PriorityTaggedServiceTraitTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; use Symfony\Component\DependencyInjection\Attribute\AsTaggedItem; @@ -171,9 +172,7 @@ public function testTheIndexedTagsByDefaultIndexMethod() $this->assertEquals($expected, $priorityTaggedServiceTraitImplementation->test($tag, $container)); } - /** - * @dataProvider provideInvalidDefaultMethods - */ + #[DataProvider('provideInvalidDefaultMethods')] public function testTheIndexedTagsByDefaultIndexMethodFailure(string $defaultIndexMethod, ?string $indexAttribute, string $expectedExceptionMessage) { $this->expectException(InvalidArgumentException::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php index 995ec4fd796f1..43760f0d9b7ae 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\TestCase; @@ -25,9 +26,7 @@ class ResolveClassPassTest extends TestCase { use ExpectDeprecationTrait; - /** - * @dataProvider provideValidClassId - */ + #[DataProvider('provideValidClassId')] public function testResolveClassFromId($serviceId) { $container = new ContainerBuilder(); @@ -43,9 +42,7 @@ public static function provideValidClassId() yield [CaseSensitiveClass::class]; } - /** - * @dataProvider provideInvalidClassId - */ + #[DataProvider('provideInvalidClassId')] public function testWontResolveClassFromId($serviceId) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveFactoryClassPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveFactoryClassPassTest.php index 8d93eeb9cbff3..13aeb9b57cb2e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveFactoryClassPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveFactoryClassPassTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Compiler\ResolveFactoryClassPass; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -55,9 +56,7 @@ public static function provideFulfilledFactories() ]; } - /** - * @dataProvider provideFulfilledFactories - */ + #[DataProvider('provideFulfilledFactories')] public function testIgnoresFulfilledFactories($factory) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php b/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php index 7749e19630161..713cd0f997a9e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Config; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Config\ContainerParametersResource; use Symfony\Component\DependencyInjection\Config\ContainerParametersResourceChecker; @@ -34,9 +35,7 @@ public function testSupports() $this->assertTrue($this->resourceChecker->supports($this->resource)); } - /** - * @dataProvider isFreshProvider - */ + #[DataProvider('isFreshProvider')] public function testIsFresh(callable $mockContainer, $expected) { $mockContainer($this->container, $this); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 3d74324a66503..a3002e59e0084 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -15,6 +15,7 @@ require_once __DIR__.'/Fixtures/includes/classes.php'; require_once __DIR__.'/Fixtures/includes/ProjectExtension.php'; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\TestCase; @@ -312,18 +313,14 @@ public function testNonSharedServicesReturnsDifferentInstances() $this->assertNotSame($builder->get('bar'), $builder->get('bar')); } - /** - * @dataProvider provideBadId - */ + #[DataProvider('provideBadId')] public function testBadAliasId($id) { $this->expectException(InvalidArgumentException::class); (new ContainerBuilder())->setAlias($id, 'foo'); } - /** - * @dataProvider provideBadId - */ + #[DataProvider('provideBadId')] public function testBadDefinitionId($id) { $this->expectException(InvalidArgumentException::class); @@ -1697,9 +1694,7 @@ public function testUninitializedReference() $this->assertEquals(['foo1' => new \stdClass(), 'foo3' => new \stdClass()], iterator_to_array($bar->iter)); } - /** - * @dataProvider provideAlmostCircular - */ + #[DataProvider('provideAlmostCircular')] public function testAlmostCircular($visibility) { $container = include __DIR__.'/Fixtures/containers/container_almost_circular.php'; diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index 5ccb1c75de194..27b1547ce388c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -34,9 +35,7 @@ public function testConstructor() $this->assertEquals(['foo' => 'bar'], $sc->getParameterBag()->all(), '__construct() takes an array of parameters as its first argument'); } - /** - * @dataProvider dataForTestCamelize - */ + #[DataProvider('dataForTestCamelize')] public function testCamelize($id, $expected) { $this->assertEquals($expected, Container::camelize($id), \sprintf('Container::camelize("%s")', $id)); @@ -58,9 +57,7 @@ public static function dataForTestCamelize() ]; } - /** - * @dataProvider dataForTestUnderscore - */ + #[DataProvider('dataForTestUnderscore')] public function testUnderscore($id, $expected) { $this->assertEquals($expected, Container::underscore($id), \sprintf('Container::underscore("%s")', $id)); diff --git a/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php b/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php index db17da4082f56..b172a3105dfb1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -27,9 +28,7 @@ public static function setUpBeforeClass(): void require_once self::$fixturesPath.'/includes/foo.php'; } - /** - * @dataProvider crossCheckLoadersDumpers - */ + #[DataProvider('crossCheckLoadersDumpers')] public function testCrossCheck($fixture, $type) { $loaderClass = 'Symfony\\Component\\DependencyInjection\\Loader\\'.ucfirst($type).'FileLoader'; diff --git a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php index 459e566d22661..08ae1325a6144 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Definition; @@ -186,9 +187,7 @@ public function testSetIsDeprecated() $this->assertSame('1.1', $deprecation['version']); } - /** - * @dataProvider invalidDeprecationMessageProvider - */ + #[DataProvider('invalidDeprecationMessageProvider')] public function testSetDeprecatedWithInvalidDeprecationTemplate($message) { $def = new Definition('stdClass'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 1eedf4a37a88c..5c2c2bab03e4a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -11,8 +11,11 @@ namespace Symfony\Component\DependencyInjection\Tests\Dumper; +use Bar\FooLazyClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Symfony\Component\Config\FileLocator; @@ -327,7 +330,7 @@ public function testDumpAsFilesWithLazyFactoriesInlined() $container->setParameter('container.dumper.inline_class_loader', true); $container->register('lazy_foo', \Bar\FooClass::class) - ->addArgument(new Definition(\Bar\FooLazyClass::class)) + ->addArgument(new Definition(FooLazyClass::class)) ->setPublic(true) ->setLazy(true); @@ -403,9 +406,7 @@ public function testConflictingMethodsWithParent() $this->assertTrue(method_exists($class, 'getFoobar2Service')); } - /** - * @dataProvider provideInvalidFactories - */ + #[DataProvider('provideInvalidFactories')] public function testInvalidFactories($factory) { $this->expectException(RuntimeException::class); @@ -779,7 +780,7 @@ public function testNonSharedLazy() $container = new ContainerBuilder(); $container - ->register('foo', \Bar\FooLazyClass::class) + ->register('foo', FooLazyClass::class) ->setFile(realpath(self::$fixturesPath.'/includes/foo_lazy.php')) ->setShared(false) ->setLazy(true) @@ -823,7 +824,7 @@ public function testNonSharedLazyAsFiles() $container = new ContainerBuilder(); $container - ->register('non_shared_foo', \Bar\FooLazyClass::class) + ->register('non_shared_foo', FooLazyClass::class) ->setFile(realpath(self::$fixturesPath.'/includes/foo_lazy.php')) ->setShared(false) ->setLazy(true) @@ -868,10 +869,8 @@ public function testNonSharedLazyAsFiles() $this->assertNotSame($foo1, $foo2); } - /** - * @testWith [false] - * [true] - */ + #[TestWith([false])] + #[TestWith([true])] public function testNonSharedLazyDefinitionReferences(bool $asGhostObject) { $container = new ContainerBuilder(); @@ -1219,9 +1218,7 @@ public function testUninitializedReference() $this->assertEquals(['foo1' => new \stdClass(), 'foo3' => new \stdClass()], iterator_to_array($bar->iter)); } - /** - * @dataProvider provideAlmostCircular - */ + #[DataProvider('provideAlmostCircular')] public function testAlmostCircular($visibility) { $container = include self::$fixturesPath.'/containers/container_almost_circular.php'; @@ -2113,9 +2110,7 @@ public function testInlineAdapterConsumer() $this->assertNotSame($fooService->factoredFromServiceWithParam, $barService->factoredFromServiceWithParam); } - /** - * @dataProvider getStripCommentsCodes - */ + #[DataProvider('getStripCommentsCodes')] public function testStripComments(string $source, string $expected) { $reflection = new \ReflectionClass(PhpDumper::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php index 548e5a18b27ec..a5a21a4dfdde3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Dumper; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Argument\AbstractArgument; @@ -110,9 +111,7 @@ public function testDumpEntities() ", $dumper->dump()); } - /** - * @dataProvider provideDecoratedServicesData - */ + #[DataProvider('provideDecoratedServicesData')] public function testDumpDecoratedServices($expectedXmlDump, $container) { $dumper = new XmlDumper($container); @@ -151,9 +150,7 @@ public static function provideDecoratedServicesData() ]; } - /** - * @dataProvider provideCompiledContainerData - */ + #[DataProvider('provideCompiledContainerData')] public function testCompiledContainerCanBeDumped($containerFile) { $fixturesPath = __DIR__.'/../Fixtures'; @@ -282,9 +279,7 @@ public function testDumpHandlesEnumeration() $this->assertEquals(file_get_contents(self::$fixturesPath.'/xml/services_with_enumeration.xml'), $dumper->dump()); } - /** - * @dataProvider provideDefaultClasses - */ + #[DataProvider('provideDefaultClasses')] public function testDumpHandlesDefaultAttribute($class, $expectedFile) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php index 3a21d7aa9a9c5..131642ac74796 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Dumper; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Argument\AbstractArgument; @@ -170,9 +171,7 @@ public function testDumpHandlesEnumeration() } } - /** - * @dataProvider provideDefaultClasses - */ + #[DataProvider('provideDefaultClasses')] public function testDumpHandlesDefaultAttribute($class, $expectedFile) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php b/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php index e5875c6282739..08ea88f13dd23 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\DependencyInjection\Tests; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Argument\RewindableGenerator; use Symfony\Component\DependencyInjection\Container; @@ -27,9 +29,7 @@ class EnvVarProcessorTest extends TestCase { public const TEST_CONST = 'test'; - /** - * @dataProvider validStrings - */ + #[DataProvider('validStrings')] public function testGetEnvString($value, $processed) { $container = new ContainerBuilder(); @@ -59,9 +59,7 @@ public static function validStrings() ]; } - /** - * @dataProvider validRealEnvValues - */ + #[DataProvider('validRealEnvValues')] public function testGetEnvRealEnv($value, $processed) { $_ENV['FOO'] = $value; @@ -120,9 +118,7 @@ public function testGetEnvRealEnvNonScalar() unset($_ENV['FOO']); } - /** - * @dataProvider validBools - */ + #[DataProvider('validBools')] public function testGetEnvBool($value, $processed) { $processor = new EnvVarProcessor(new Container()); @@ -198,9 +194,7 @@ public function loadEnvVars(): array unset($_ENV['FOO'], $GLOBALS['ENV_FOO']); } - /** - * @dataProvider validBools - */ + #[DataProvider('validBools')] public function testGetEnvNot($value, $processed) { $processor = new EnvVarProcessor(new Container()); @@ -228,9 +222,7 @@ public static function validBools() ]; } - /** - * @dataProvider validInts - */ + #[DataProvider('validInts')] public function testGetEnvInt($value, $processed) { $processor = new EnvVarProcessor(new Container()); @@ -253,9 +245,7 @@ public static function validInts() ]; } - /** - * @dataProvider invalidInts - */ + #[DataProvider('invalidInts')] public function testGetEnvIntInvalid($value) { $processor = new EnvVarProcessor(new Container()); @@ -279,9 +269,7 @@ public static function invalidInts() ]; } - /** - * @dataProvider validFloats - */ + #[DataProvider('validFloats')] public function testGetEnvFloat($value, $processed) { $processor = new EnvVarProcessor(new Container()); @@ -304,9 +292,7 @@ public static function validFloats() ]; } - /** - * @dataProvider invalidFloats - */ + #[DataProvider('invalidFloats')] public function testGetEnvFloatInvalid($value) { $processor = new EnvVarProcessor(new Container()); @@ -330,9 +316,7 @@ public static function invalidFloats() ]; } - /** - * @dataProvider validConsts - */ + #[DataProvider('validConsts')] public function testGetEnvConst($value, $processed) { $processor = new EnvVarProcessor(new Container()); @@ -354,9 +338,7 @@ public static function validConsts() ]; } - /** - * @dataProvider invalidConsts - */ + #[DataProvider('invalidConsts')] public function testGetEnvConstInvalid($value) { $processor = new EnvVarProcessor(new Container()); @@ -411,9 +393,7 @@ public function testGetEnvTrim() $this->assertSame('hello', $result); } - /** - * @dataProvider validJson - */ + #[DataProvider('validJson')] public function testGetEnvJson($value, $processed) { $processor = new EnvVarProcessor(new Container()); @@ -450,9 +430,7 @@ public function testGetEnvInvalidJson() }); } - /** - * @dataProvider otherJsonValues - */ + #[DataProvider('otherJsonValues')] public function testGetEnvJsonOther($value) { $processor = new EnvVarProcessor(new Container()); @@ -504,9 +482,7 @@ public function testGetEnvKeyInvalidKey() }); } - /** - * @dataProvider noArrayValues - */ + #[DataProvider('noArrayValues')] public function testGetEnvKeyNoArrayResult($value) { $processor = new EnvVarProcessor(new Container()); @@ -531,9 +507,7 @@ public static function noArrayValues() ]; } - /** - * @dataProvider invalidArrayValues - */ + #[DataProvider('invalidArrayValues')] public function testGetEnvKeyArrayKeyNotFound($value) { $processor = new EnvVarProcessor(new Container()); @@ -557,9 +531,7 @@ public static function invalidArrayValues() ]; } - /** - * @dataProvider arrayValues - */ + #[DataProvider('arrayValues')] public function testGetEnvKey($value) { $processor = new EnvVarProcessor(new Container()); @@ -599,9 +571,7 @@ public function testGetEnvKeyChained() })); } - /** - * @dataProvider provideGetEnvEnum - */ + #[DataProvider('provideGetEnvEnum')] public function testGetEnvEnum(\BackedEnum $backedEnum) { $processor = new EnvVarProcessor(new Container()); @@ -665,9 +635,7 @@ public function testGetEnvEnumInvalidBackedValue() $processor->getEnv('enum', StringBackedEnum::class.':foo', fn () => 'bogus'); } - /** - * @dataProvider validNullables - */ + #[DataProvider('validNullables')] public function testGetEnvNullable($value, $processed) { $processor = new EnvVarProcessor(new Container()); @@ -715,9 +683,7 @@ public function testRequireFile() $this->assertEquals('foo', $result); } - /** - * @dataProvider validResolve - */ + #[DataProvider('validResolve')] public function testGetEnvResolve($value, $processed) { $container = new ContainerBuilder(); @@ -751,9 +717,7 @@ public function testGetEnvResolveNoMatch() $this->assertSame('%', $result); } - /** - * @dataProvider notScalarResolve - */ + #[DataProvider('notScalarResolve')] public function testGetEnvResolveNotScalar($value) { $container = new ContainerBuilder(); @@ -808,9 +772,7 @@ public function testGetEnvResolveNestedRealEnv() unset($_ENV['BAR']); } - /** - * @dataProvider validCsv - */ + #[DataProvider('validCsv')] public function testGetEnvCsv($value, $processed) { $processor = new EnvVarProcessor(new Container()); @@ -976,9 +938,7 @@ public function testGetEnvInvalidPrefixWithDefault() }); } - /** - * @dataProvider provideGetEnvUrlPath - */ + #[DataProvider('provideGetEnvUrlPath')] public function testGetEnvUrlPath(?string $expected, string $url) { $this->assertSame($expected, (new EnvVarProcessor(new Container()))->getEnv('url', 'foo', static fn (): string => $url)['path']); @@ -996,18 +956,16 @@ public static function provideGetEnvUrlPath() ]; } - /** - * @testWith ["http://foo.com\\bar"] - * ["\\\\foo.com/bar"] - * ["a\rb"] - * ["a\nb"] - * ["a\tb"] - * ["\u0000foo"] - * ["foo\u0000"] - * [" foo"] - * ["foo "] - * [":"] - */ + #[TestWith(['http://foo.com\\bar'])] + #[TestWith(['\\\\foo.com/bar'])] + #[TestWith(["a\rb"])] + #[TestWith(["a\nb"])] + #[TestWith(["a\tb"])] + #[TestWith(["\u0000foo"])] + #[TestWith(["foo\u0000"])] + #[TestWith([' foo'])] + #[TestWith(['foo '])] + #[TestWith([':'])] public function testGetEnvBadUrl(string $url) { $this->expectException(RuntimeException::class); @@ -1017,14 +975,12 @@ public function testGetEnvBadUrl(string $url) }); } - /** - * @testWith ["", "string"] - * [null, ""] - * [false, "bool"] - * [true, "not"] - * [0, "int"] - * [0.0, "float"] - */ + #[TestWith(['', 'string'])] + #[TestWith([null, ''])] + #[TestWith([false, 'bool'])] + #[TestWith([true, 'not'])] + #[TestWith([0, 'int'])] + #[TestWith([0.0, 'float'])] public function testGetEnvCastsNullBehavior($expected, string $prefix) { $processor = new EnvVarProcessor(new Container()); @@ -1049,9 +1005,7 @@ public function testGetEnvWithEmptyStringPrefixCastsToString() } } - /** - * @dataProvider provideGetEnvDefined - */ + #[DataProvider('provideGetEnvDefined')] public function testGetEnvDefined(bool $expected, callable $callback) { $this->assertSame($expected, (new EnvVarProcessor(new Container()))->getEnv('defined', 'NO_SOMETHING', $callback)); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Exception/InvalidParameterTypeExceptionTest.php b/src/Symfony/Component/DependencyInjection/Tests/Exception/InvalidParameterTypeExceptionTest.php index ef88c71cad9c7..3f3178d44a0d5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Exception/InvalidParameterTypeExceptionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Exception/InvalidParameterTypeExceptionTest.php @@ -11,14 +11,13 @@ namespace Symfony\Component\DependencyInjection\Tests\Exception; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Exception\InvalidParameterTypeException; final class InvalidParameterTypeExceptionTest extends TestCase { - /** - * @dataProvider provideReflectionParameters - */ + #[DataProvider('provideReflectionParameters')] public function testExceptionMessage(\ReflectionParameter $parameter, string $expectedMessage) { $exception = new InvalidParameterTypeException('my_service', 'int', $parameter); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php b/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php index d2b5128c0f8e6..8a35ebb8f9f9b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Extension; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; @@ -23,9 +24,7 @@ class ExtensionTest extends TestCase { - /** - * @dataProvider getResolvedEnabledFixtures - */ + #[DataProvider('getResolvedEnabledFixtures')] public function testIsConfigEnabledReturnsTheResolvedValue($enabled) { $extension = new EnableableExtension(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/PhpDumper/LazyServiceDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/PhpDumper/LazyServiceDumperTest.php index 1d5e9b6bf2dcf..ba5a0a5e827b4 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/PhpDumper/LazyServiceDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/PhpDumper/LazyServiceDumperTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\LazyProxy\PhpDumper; +use PHPUnit\Framework\Attributes\RequiresPhp; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\Definition; @@ -65,9 +66,7 @@ public function testInvalidClass() $dumper->getProxyCode($definition); } - /** - * @requires PHP 8.3 - */ + #[RequiresPhp('8.3')] public function testReadonlyClass() { $dumper = new LazyServiceDumper(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/Configurator/EnvConfiguratorTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/Configurator/EnvConfiguratorTest.php index 75ddca1e632cc..fecc7b8e9a4a5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/Configurator/EnvConfiguratorTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/Configurator/EnvConfiguratorTest.php @@ -11,15 +11,14 @@ namespace Symfony\Component\DependencyInjection\Tests\Loader\Configurator; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Loader\Configurator\EnvConfigurator; use Symfony\Component\DependencyInjection\Tests\Fixtures\StringBackedEnum; final class EnvConfiguratorTest extends TestCase { - /** - * @dataProvider provide - */ + #[DataProvider('provide')] public function test(string $expected, EnvConfigurator $envConfigurator) { $this->assertSame($expected, (string) $envConfigurator); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php index 17bc228c77b82..9cff05941f61a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\DependencyInjection\Tests\Loader; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\Loader\LoaderResolver; @@ -152,10 +154,8 @@ public function testRegisterClassesWithExclude() ); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testRegisterClassesWithExcludeAttribute(bool $autoconfigure) { $container = new ContainerBuilder(); @@ -260,9 +260,7 @@ public function testRegisterClassesWithIncompatibleExclude() ); } - /** - * @dataProvider excludeTrailingSlashConsistencyProvider - */ + #[DataProvider('excludeTrailingSlashConsistencyProvider')] public function testExcludeTrailingSlashConsistency(string $exclude, string $excludedId) { $container = new ContainerBuilder(); @@ -290,12 +288,10 @@ public static function excludeTrailingSlashConsistencyProvider(): iterable yield ['Prototype/OtherDir/AnotherSub/DeeperBaz.php', DeeperBaz::class]; } - /** - * @testWith ["prod", false] - * ["dev", false] - * ["bar", true] - * [null, false] - */ + #[TestWith(['prod', false])] + #[TestWith(['dev', false])] + #[TestWith(['bar', true])] + #[TestWith([null, false])] public function testRegisterClassesWithWhenEnv(?string $env, bool $expected) { $container = new ContainerBuilder(); @@ -309,9 +305,7 @@ public function testRegisterClassesWithWhenEnv(?string $env, bool $expected) $this->assertSame($expected, $container->getDefinition(Foo::class)->hasTag('container.excluded')); } - /** - * @dataProvider provideEnvAndExpectedExclusions - */ + #[DataProvider('provideEnvAndExpectedExclusions')] public function testRegisterWithNotWhenAttributes(string $env, bool $expectedNotFooExclusion) { $container = new ContainerBuilder(); @@ -350,9 +344,7 @@ public function testRegisterThrowsWithBothWhenAndNotWhenAttribute() ); } - /** - * @dataProvider provideResourcesWithAsAliasAttributes - */ + #[DataProvider('provideResourcesWithAsAliasAttributes')] public function testRegisterClassesWithAsAlias(string $resource, array $expectedAliases, ?string $env = null) { $container = new ContainerBuilder(); @@ -391,9 +383,7 @@ public static function provideResourcesWithAsAliasAttributes(): iterable yield 'Test-env specific' => ['PrototypeAsAlias/WithAsAlias*Env.php', [], 'test']; } - /** - * @dataProvider provideResourcesWithDuplicatedAsAliasAttributes - */ + #[DataProvider('provideResourcesWithDuplicatedAsAliasAttributes')] public function testRegisterClassesWithDuplicatedAsAlias(string $resource, string $expectedExceptionMessage) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php index 1c757eea5bc9e..c3825fbb9271d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Loader; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -34,9 +35,7 @@ public function testIniFileCanBeLoaded() $this->assertEquals(['foo' => 'bar', 'bar' => '%foo%'], $this->container->getParameterBag()->all(), '->load() takes a single file name as its first argument'); } - /** - * @dataProvider getTypeConversions - */ + #[DataProvider('getTypeConversions')] public function testTypeConversions($key, $value, $supported) { $this->loader->load('types.ini'); @@ -45,9 +44,9 @@ public function testTypeConversions($key, $value, $supported) } /** - * @dataProvider getTypeConversions - * This test illustrates where our conversions differs from INI_SCANNER_TYPED introduced in PHP 5.6.1 + * This test illustrates where our conversions differs from INI_SCANNER_TYPED introduced in PHP 5.6.1. */ + #[DataProvider('getTypeConversions')] public function testTypeConversionsWithNativePhp($key, $value, $supported) { if (!$supported) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/LoaderResolverTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/LoaderResolverTest.php index 996cc524149fe..3b3622c8b7ed4 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/LoaderResolverTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/LoaderResolverTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Loader; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\Loader\LoaderResolver; @@ -51,9 +52,7 @@ public static function provideResourcesToLoad() ]; } - /** - * @dataProvider provideResourcesToLoad - */ + #[DataProvider('provideResourcesToLoad')] public function testResolvesForcedType($resource, $type, $expectedClass) { $this->assertInstanceOf($expectedClass, $this->resolver->resolve($resource, $type)); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php index 9ca0104eaaf6c..c54f31f779b47 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php @@ -14,6 +14,7 @@ require_once __DIR__.'/../Fixtures/includes/AcmeExtension.php'; require_once __DIR__.'/../Fixtures/includes/fixture_app_services.php'; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Builder\ConfigBuilderGenerator; use Symfony\Component\Config\FileLocator; @@ -104,9 +105,7 @@ public function testConfigServiceClosure() $this->assertStringEqualsFile($fixtures.'/php/services_closure_argument_compiled.php', $dumper->dump()); } - /** - * @dataProvider provideConfig - */ + #[DataProvider('provideConfig')] public function testConfig($file) { $fixtures = realpath(__DIR__.'/../Fixtures'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index f6ff7b8fe6d6b..0079ccfcfc7cd 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -11,8 +11,10 @@ namespace Symfony\Component\DependencyInjection\Tests\Loader; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException; use Symfony\Component\Config\Exception\LoaderLoadException; @@ -378,10 +380,8 @@ public function testParsesIteratorArgument() $this->assertEquals([new IteratorArgument(['k1' => new Reference('foo.baz'), 'k2' => new Reference('service_container')]), new IteratorArgument([])], $lazyDefinition->getArguments(), '->load() parses lazy arguments'); } - /** - * @testWith ["foo_tag"] - * ["bar_tag"] - */ + #[TestWith(['foo_tag'])] + #[TestWith(['bar_tag'])] public function testParsesTags(string $tag) { $container = new ContainerBuilder(); @@ -814,9 +814,7 @@ public function testPrototype() $this->assertContains('reflection.Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar', $resources); } - /** - * @dataProvider prototypeExcludeWithArrayDataProvider - */ + #[DataProvider('prototypeExcludeWithArrayDataProvider')] public function testPrototypeExcludeWithArray(string $fileName) { $container = new ContainerBuilder(); @@ -1218,9 +1216,7 @@ public function testClosure() $this->assertEquals((new Definition('Closure'))->setFactory(['Closure', 'fromCallable'])->addArgument(new Reference('bar')), $definition); } - /** - * @dataProvider dataForBindingsAndInnerCollections - */ + #[DataProvider('dataForBindingsAndInnerCollections')] public function testBindingsAndInnerCollections($bindName, $expected) { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index d4ae212b5f506..bf142e59fa234 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Loader; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\TestCase; @@ -81,9 +82,7 @@ public function testLoadInvalidYamlFile() $m->invoke($loader, $path.'/parameters.ini'); } - /** - * @dataProvider provideInvalidFiles - */ + #[DataProvider('provideInvalidFiles')] public function testLoadInvalidFile($file) { $this->expectException(InvalidArgumentException::class); @@ -587,9 +586,7 @@ public function testPrototype() $this->assertContains('reflection.Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar', $resources); } - /** - * @dataProvider prototypeWithNullOrEmptyNodeDataProvider - */ + #[DataProvider('prototypeWithNullOrEmptyNodeDataProvider')] public function testPrototypeWithNullOrEmptyNode(string $fileName) { $this->expectException(InvalidArgumentException::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php index 38ef6fcd15ffb..d0066737f1318 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php @@ -11,8 +11,10 @@ namespace Symfony\Component\DependencyInjection\Tests\ParameterBag; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Exception\EmptyParameterValueException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; @@ -82,10 +84,8 @@ public function testGetSet() } } - /** - * @testWith [1001] - * [10.0] - */ + #[TestWith([1001])] + #[TestWith([10.0])] public function testSetNumericName(int|float $name) { $bag = new ParameterBag(); @@ -96,10 +96,8 @@ public function testSetNumericName(int|float $name) $bag->set($name, 'foo'); } - /** - * @testWith [1001] - * [10.0] - */ + #[TestWith([1001])] + #[TestWith([10.0])] public function testConstructorNumericName(int|float $name) { $this->expectException(InvalidArgumentException::class); @@ -108,9 +106,7 @@ public function testConstructorNumericName(int|float $name) new ParameterBag([$name => 'foo']); } - /** - * @dataProvider provideGetThrowParameterNotFoundExceptionData - */ + #[DataProvider('provideGetThrowParameterNotFoundExceptionData')] public function testGetThrowParameterNotFoundException($parameterKey, $exceptionMessage) { $bag = new ParameterBag([ @@ -379,9 +375,7 @@ public function testEscapeValue() $this->assertEquals(['bar' => ['ding' => 'I\'m a bar %%foo %%bar', 'zero' => null]], $bag->get('foo'), '->escapeValue() escapes % by doubling it'); } - /** - * @dataProvider stringsWithSpacesProvider - */ + #[DataProvider('stringsWithSpacesProvider')] public function testResolveStringWithSpacesReturnsString($expected, $test, $description) { $bag = new ParameterBag(['foo' => 'bar']); diff --git a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php index 53169efcab8e5..a2b6c434b2668 100644 --- a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php +++ b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php @@ -11,6 +11,9 @@ namespace Symfony\Component\DomCrawler\Tests; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; +use PHPUnit\Framework\Error\Notice; use PHPUnit\Framework\TestCase; use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Form; @@ -104,9 +107,7 @@ public function testAddHtmlContentWithBaseTag() $this->assertEquals('http://symfony.com/contact', $crawler->filterXPath('//a')->link()->getUri(), '->addHtmlContent() adds nodes from an HTML string'); } - /** - * @requires extension mbstring - */ + #[RequiresPhpExtension('mbstring')] public function testAddHtmlContentCharset() { $crawler = $this->createCrawler(); @@ -123,9 +124,7 @@ public function testAddHtmlContentInvalidBaseTag() $this->assertEquals('http://symfony.com/contact', current($crawler->filterXPath('//a')->links())->getUri(), '->addHtmlContent() correctly handles a non-existent base tag href attribute'); } - /** - * @requires extension mbstring - */ + #[RequiresPhpExtension('mbstring')] public function testAddHtmlContentCharsetGbk() { $crawler = $this->createCrawler(); @@ -190,9 +189,7 @@ public function testAddContent() $this->assertEquals('var foo = "bär";', $crawler->filterXPath('//script')->text(), '->addContent() does not interfere with script content'); } - /** - * @requires extension iconv - */ + #[RequiresPhpExtension('iconv')] public function testAddContentNonUtf8() { $crawler = $this->createCrawler(); @@ -393,9 +390,7 @@ public static function provideInnerTextExamples() ]; } - /** - * @dataProvider provideInnerTextExamples - */ + #[DataProvider('provideInnerTextExamples')] public function testInnerText( string $xPathQuery, string $expectedText, @@ -975,7 +970,7 @@ public static function provideMatchTests() yield ['#bar', false, '.foo']; } - /** @dataProvider provideMatchTests */ + #[DataProvider('provideMatchTests')] public function testMatch(string $mainNodeSelector, bool $expected, string $selector) { $html = <<<'HTML' @@ -1143,7 +1138,7 @@ public function testChildren() $crawler = $this->createCrawler('

'); $crawler->filter('p')->children(); $this->assertTrue(true, '->children() does not trigger a notice if the node has no children'); - } catch (\PHPUnit\Framework\Error\Notice $e) { + } catch (Notice $e) { $this->fail('->children() does not trigger a notice if the node has no children'); } } @@ -1199,9 +1194,7 @@ public function testAncestorsThrowsIfNodeListIsEmpty() $this->createTestCrawler()->filterXPath('//ol')->ancestors(); } - /** - * @dataProvider getBaseTagData - */ + #[DataProvider('getBaseTagData')] public function testBaseTag($baseValue, $linkValue, $expectedUri, $currentUri = null, $description = '') { $crawler = $this->createCrawler($this->getDoctype().'', $currentUri); @@ -1219,9 +1212,7 @@ public static function getBaseTagData() ]; } - /** - * @dataProvider getBaseTagWithFormData - */ + #[DataProvider('getBaseTagWithFormData')] public function testBaseTagWithForm($baseValue, $actionValue, $expectedUri, $currentUri = null, $description = null) { $crawler = $this->createCrawler($this->getDoctype().'