Skip to content

Commit 4d7352a

Browse files
authored
fix tests by adjusting switch for enabling annotations (#1734)
1 parent 4194459 commit 4d7352a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Tests/DependencyInjection/AbstractDoctrineExtensionTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
use Symfony\Component\DependencyInjection\Reference;
3939
use Symfony\Component\DependencyInjection\ServiceLocator;
4040
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
41+
use Symfony\Component\HttpKernel\Kernel;
4142
use Symfony\Component\Security\Core\User\UserInterface;
42-
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
4343

4444
use function array_filter;
4545
use function array_intersect_key;
@@ -55,6 +55,7 @@
5555
use function sprintf;
5656
use function sys_get_temp_dir;
5757
use function uniqid;
58+
use function version_compare;
5859

5960
use const DIRECTORY_SEPARATOR;
6061

@@ -537,7 +538,7 @@ public function testSingleEntityManagerMultipleMappingBundleDefinitions(): void
537538
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
538539

539540
$this->assertDICDefinitionMethodCallAt(0, $definition, 'addDriver', [
540-
new Reference(class_exists(AnnotationLoader::class) ? 'doctrine.orm.default_annotation_metadata_driver' : 'doctrine.orm.default_attribute_metadata_driver'),
541+
new Reference(version_compare(Kernel::VERSION, '7.0.0', '<') ? 'doctrine.orm.default_annotation_metadata_driver' : 'doctrine.orm.default_attribute_metadata_driver'),
541542
'Fixtures\Bundles\AnnotationsBundle\Entity',
542543
]);
543544

@@ -559,7 +560,7 @@ public function testSingleEntityManagerMultipleMappingBundleDefinitions(): void
559560
$attrDef = $container->getDefinition('doctrine.orm.default_attribute_metadata_driver');
560561
$this->assertDICConstructorArguments($attrDef, [
561562
array_merge(
562-
! class_exists(AnnotationLoader::class) ? [
563+
! version_compare(Kernel::VERSION, '7.0.0', '<') ? [
563564
__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AnnotationsBundle' . DIRECTORY_SEPARATOR . 'Entity',
564565
] : [],
565566
[
@@ -596,7 +597,7 @@ public function testMultipleEntityManagersMappingBundleDefinitions(): void
596597

597598
$def1 = $container->getDefinition('doctrine.orm.em1_metadata_driver');
598599
$def2 = $container->getDefinition('doctrine.orm.em2_metadata_driver');
599-
$def1Id = class_exists(AnnotationLoader::class) ? 'doctrine.orm.em1_annotation_metadata_driver' : 'doctrine.orm.em1_attribute_metadata_driver';
600+
$def1Id = version_compare(Kernel::VERSION, '7.0.0', '<') ? 'doctrine.orm.em1_annotation_metadata_driver' : 'doctrine.orm.em1_attribute_metadata_driver';
600601

601602
$this->assertDICDefinitionMethodCallAt(0, $def1, 'addDriver', [
602603
new Reference($def1Id),
@@ -618,7 +619,7 @@ public function testMultipleEntityManagersMappingBundleDefinitions(): void
618619
'Fixtures\Bundles\XmlBundle',
619620
]);
620621

621-
if (class_exists(AnnotationLoader::class)) {
622+
if (version_compare(Kernel::VERSION, '7.0.0', '<')) {
622623
$annDef = $container->getDefinition($def1Id);
623624
$this->assertDICConstructorArguments($annDef, [
624625
new Reference('doctrine.orm.metadata.annotation_reader'),

Tests/DependencyInjection/Fixtures/DbalTestKernel.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44

55
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
66
use Doctrine\Bundle\DoctrineBundle\Tests\TestCaseAllPublicCompilerPass;
7-
use Doctrine\Common\Annotations\Annotation;
87
use Psr\Log\NullLogger;
98
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
109
use Symfony\Component\Config\Loader\LoaderInterface;
1110
use Symfony\Component\DependencyInjection\ContainerBuilder;
1211
use Symfony\Component\HttpKernel\Bundle\Bundle;
1312
use Symfony\Component\HttpKernel\Kernel;
1413

15-
use function class_exists;
1614
use function md5;
1715
use function mt_rand;
1816
use function sys_get_temp_dir;
17+
use function version_compare;
1918

2019
class DbalTestKernel extends Kernel
2120
{
@@ -48,7 +47,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
4847
'secret' => 'F00',
4948
'http_method_override' => false,
5049
'annotations' => [
51-
'enabled' => class_exists(Annotation::class),
50+
'enabled' => version_compare(Kernel::VERSION, '7.0.0', '<'),
5251
],
5352
]);
5453

0 commit comments

Comments
 (0)