Skip to content

Commit

Permalink
fix tests with Symfony 7 due to Annotation support removal
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher committed Oct 22, 2023
1 parent 8ab2a63 commit 4452bb2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
34 changes: 21 additions & 13 deletions Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use function array_filter;
use function array_intersect_key;
use function array_keys;
use function array_merge;
use function array_values;
use function assert;
use function class_exists;
Expand Down Expand Up @@ -489,7 +490,7 @@ public function testSingleEntityManagerMultipleMappingBundleDefinitions(): void
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');

$this->assertDICDefinitionMethodCallAt(0, $definition, 'addDriver', [
new Reference('doctrine.orm.default_annotation_metadata_driver'),
new Reference($container->has('annotations.reader') ? 'doctrine.orm.default_annotation_metadata_driver' : 'doctrine.orm.default_attribute_metadata_driver'),
'Fixtures\Bundles\AnnotationsBundle\Entity',
]);

Expand All @@ -510,9 +511,14 @@ public function testSingleEntityManagerMultipleMappingBundleDefinitions(): void

$attrDef = $container->getDefinition('doctrine.orm.default_attribute_metadata_driver');
$this->assertDICConstructorArguments($attrDef, [
[
__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AttributesBundle' . DIRECTORY_SEPARATOR . 'Entity',
],
array_merge(
! $container->has('annotations.reader') ? [
__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AnnotationsBundle' . DIRECTORY_SEPARATOR . 'Entity',
] : [],
[
__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AttributesBundle' . DIRECTORY_SEPARATOR . 'Entity',
]
),
false,
]);

Expand Down Expand Up @@ -543,7 +549,7 @@ public function testMultipleEntityManagersMappingBundleDefinitions(): void

$def1 = $container->getDefinition('doctrine.orm.em1_metadata_driver');
$def2 = $container->getDefinition('doctrine.orm.em2_metadata_driver');
$def1Id = 'doctrine.orm.em1_annotation_metadata_driver';
$def1Id = $container->has('annotations.reader') ? 'doctrine.orm.em1_annotation_metadata_driver' : 'doctrine.orm.em1_attribute_metadata_driver';

$this->assertDICDefinitionMethodCallAt(0, $def1, 'addDriver', [
new Reference($def1Id),
Expand All @@ -565,14 +571,16 @@ public function testMultipleEntityManagersMappingBundleDefinitions(): void
'Fixtures\Bundles\XmlBundle',
]);

$annDef = $container->getDefinition($def1Id);
$this->assertDICConstructorArguments($annDef, [
new Reference('doctrine.orm.metadata.annotation_reader'),
[
__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AnnotationsBundle' . DIRECTORY_SEPARATOR . 'Entity',
],
false,
]);
if ($container->has('annotations.reader')) {
$annDef = $container->getDefinition($def1Id);
$this->assertDICConstructorArguments($annDef, [
new Reference('doctrine.orm.metadata.annotation_reader'),
[
__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AnnotationsBundle' . DIRECTORY_SEPARATOR . 'Entity',
],
false,
]);
}

$ymlDef = $container->getDefinition('doctrine.orm.em2_yml_metadata_driver');
$this->assertDICConstructorArguments($ymlDef, [
Expand Down
8 changes: 6 additions & 2 deletions Tests/DependencyInjection/DoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,9 @@ public function testAnnotationsBundleMappingDetection(): void

$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
$this->assertDICDefinitionMethodCallOnce($definition, 'addDriver', [
new Reference('doctrine.orm.default_annotation_metadata_driver'),
new Reference($container->has('annotations.reader')
? 'doctrine.orm.default_annotation_metadata_driver'
: 'doctrine.orm.default_attribute_metadata_driver'),
'Fixtures\Bundles\AnnotationsBundle\Entity',
]);
}
Expand Down Expand Up @@ -925,7 +927,9 @@ public function testOrmMergeConfigs(): void

$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
$this->assertDICDefinitionMethodCallAt(0, $definition, 'addDriver', [
new Reference('doctrine.orm.default_annotation_metadata_driver'),
new Reference($container->has('annotations.reader')
? 'doctrine.orm.default_annotation_metadata_driver'
: 'doctrine.orm.default_attribute_metadata_driver'),
'Fixtures\Bundles\AnnotationsBundle\Entity',
]);
$this->assertDICDefinitionMethodCallAt(1, $definition, 'addDriver', [
Expand Down

0 comments on commit 4452bb2

Please sign in to comment.