diff --git a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php index daa094d4..fc46b8ff 100644 --- a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php +++ b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php @@ -38,8 +38,8 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; +use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Security\Core\User\UserInterface; -use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader; use function array_filter; use function array_intersect_key; @@ -55,6 +55,7 @@ use function sprintf; use function sys_get_temp_dir; use function uniqid; +use function version_compare; use const DIRECTORY_SEPARATOR; @@ -537,7 +538,7 @@ public function testSingleEntityManagerMultipleMappingBundleDefinitions(): void $definition = $container->getDefinition('doctrine.orm.default_metadata_driver'); $this->assertDICDefinitionMethodCallAt(0, $definition, 'addDriver', [ - new Reference(class_exists(AnnotationLoader::class) ? 'doctrine.orm.default_annotation_metadata_driver' : 'doctrine.orm.default_attribute_metadata_driver'), + new Reference(version_compare(Kernel::VERSION, '7.0.0', '<') ? 'doctrine.orm.default_annotation_metadata_driver' : 'doctrine.orm.default_attribute_metadata_driver'), 'Fixtures\Bundles\AnnotationsBundle\Entity', ]); @@ -559,7 +560,7 @@ public function testSingleEntityManagerMultipleMappingBundleDefinitions(): void $attrDef = $container->getDefinition('doctrine.orm.default_attribute_metadata_driver'); $this->assertDICConstructorArguments($attrDef, [ array_merge( - ! class_exists(AnnotationLoader::class) ? [ + ! version_compare(Kernel::VERSION, '7.0.0', '<') ? [ __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AnnotationsBundle' . DIRECTORY_SEPARATOR . 'Entity', ] : [], [ @@ -596,7 +597,7 @@ public function testMultipleEntityManagersMappingBundleDefinitions(): void $def1 = $container->getDefinition('doctrine.orm.em1_metadata_driver'); $def2 = $container->getDefinition('doctrine.orm.em2_metadata_driver'); - $def1Id = class_exists(AnnotationLoader::class) ? 'doctrine.orm.em1_annotation_metadata_driver' : 'doctrine.orm.em1_attribute_metadata_driver'; + $def1Id = version_compare(Kernel::VERSION, '7.0.0', '<') ? 'doctrine.orm.em1_annotation_metadata_driver' : 'doctrine.orm.em1_attribute_metadata_driver'; $this->assertDICDefinitionMethodCallAt(0, $def1, 'addDriver', [ new Reference($def1Id), @@ -618,7 +619,7 @@ public function testMultipleEntityManagersMappingBundleDefinitions(): void 'Fixtures\Bundles\XmlBundle', ]); - if (class_exists(AnnotationLoader::class)) { + if (version_compare(Kernel::VERSION, '7.0.0', '<')) { $annDef = $container->getDefinition($def1Id); $this->assertDICConstructorArguments($annDef, [ new Reference('doctrine.orm.metadata.annotation_reader'), diff --git a/Tests/DependencyInjection/Fixtures/DbalTestKernel.php b/Tests/DependencyInjection/Fixtures/DbalTestKernel.php index 32d17a26..3709f052 100644 --- a/Tests/DependencyInjection/Fixtures/DbalTestKernel.php +++ b/Tests/DependencyInjection/Fixtures/DbalTestKernel.php @@ -4,7 +4,6 @@ use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; use Doctrine\Bundle\DoctrineBundle\Tests\TestCaseAllPublicCompilerPass; -use Doctrine\Common\Annotations\Annotation; use Psr\Log\NullLogger; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Component\Config\Loader\LoaderInterface; @@ -12,10 +11,10 @@ use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\HttpKernel\Kernel; -use function class_exists; use function md5; use function mt_rand; use function sys_get_temp_dir; +use function version_compare; class DbalTestKernel extends Kernel { @@ -48,7 +47,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void 'secret' => 'F00', 'http_method_override' => false, 'annotations' => [ - 'enabled' => class_exists(Annotation::class), + 'enabled' => version_compare(Kernel::VERSION, '7.0.0', '<'), ], ]);