Skip to content

Commit

Permalink
Remove the AnnotationsBundle from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MatTheCat committed Nov 4, 2024
1 parent 78d3558 commit 27cf0be
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 47 deletions.
36 changes: 7 additions & 29 deletions tests/DependencyInjection/AbstractDoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,26 +543,21 @@ public function testSingleEntityManagerMultipleMappingBundleDefinitions(): void
self::markTestSkipped('This test requires ORM');
}

$container = $this->loadContainer('orm_single_em_bundle_mappings', ['YamlBundle', 'AnnotationsBundle', 'XmlBundle', 'AttributesBundle']);
$container = $this->loadContainer('orm_single_em_bundle_mappings', ['YamlBundle', 'XmlBundle', 'AttributesBundle']);

$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');

$this->assertDICDefinitionMethodCallAt(0, $definition, 'addDriver', [
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',
]);

$this->assertDICDefinitionMethodCallAt(1, $definition, 'addDriver', [
new Reference('doctrine.orm.default_attribute_metadata_driver'),
'Fixtures\Bundles\AttributesBundle\Entity',
]);

$this->assertDICDefinitionMethodCallAt(2, $definition, 'addDriver', [
$this->assertDICDefinitionMethodCallAt(1, $definition, 'addDriver', [
new Reference('doctrine.orm.default_yml_metadata_driver'),
'Fixtures\Bundles\YamlBundle\Entity',
]);

$this->assertDICDefinitionMethodCallAt(3, $definition, 'addDriver', [
$this->assertDICDefinitionMethodCallAt(2, $definition, 'addDriver', [
new Reference('doctrine.orm.default_xml_metadata_driver'),
'Fixtures\Bundles\XmlBundle',
]);
Expand Down Expand Up @@ -600,21 +595,15 @@ public function testMultipleEntityManagersMappingBundleDefinitions(): void
self::markTestSkipped('This test requires ORM');
}

$container = $this->loadContainer('orm_multiple_em_bundle_mappings', ['YamlBundle', 'AnnotationsBundle', 'XmlBundle', 'AttributesBundle']);
$container = $this->loadContainer('orm_multiple_em_bundle_mappings', ['YamlBundle', 'XmlBundle', 'AttributesBundle']);

$this->assertEquals(['em1' => 'doctrine.orm.em1_entity_manager', 'em2' => 'doctrine.orm.em2_entity_manager'], $container->getParameter('doctrine.entity_managers'), 'Set of the existing EntityManagers names is incorrect.');
$this->assertEquals('%doctrine.entity_managers%', $container->getDefinition('doctrine')->getArgument(2), 'Set of the existing EntityManagers names is incorrect.');

$def1 = $container->getDefinition('doctrine.orm.em1_metadata_driver');
$def2 = $container->getDefinition('doctrine.orm.em2_metadata_driver');
$def1Id = version_compare(Kernel::VERSION, '7.0.0', '<') ? 'doctrine.orm.em1_annotation_metadata_driver' : 'doctrine.orm.em1_attribute_metadata_driver';
$def1 = $container->getDefinition('doctrine.orm.em1_metadata_driver');
$def2 = $container->getDefinition('doctrine.orm.em2_metadata_driver');

$this->assertDICDefinitionMethodCallAt(0, $def1, 'addDriver', [
new Reference($def1Id),
'Fixtures\Bundles\AnnotationsBundle\Entity',
]);

$this->assertDICDefinitionMethodCallAt(1, $def1, 'addDriver', [
new Reference('doctrine.orm.em1_attribute_metadata_driver'),
'Fixtures\Bundles\AttributesBundle\Entity',
]);
Expand All @@ -629,17 +618,6 @@ public function testMultipleEntityManagersMappingBundleDefinitions(): void
'Fixtures\Bundles\XmlBundle',
]);

if (version_compare(Kernel::VERSION, '7.0.0', '<')) {
$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',
],
! class_exists(AnnotationDriver::class),
]);
}

$ymlDef = $container->getDefinition('doctrine.orm.em2_yml_metadata_driver');
$this->assertDICConstructorArguments($ymlDef, [
[__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'YamlBundle' . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'doctrine' => 'Fixtures\Bundles\YamlBundle\Entity'],
Expand All @@ -659,7 +637,7 @@ public function testSingleEntityManagerDefaultTableOptions(): void
self::markTestSkipped('This test requires ORM');
}

$container = $this->loadContainer('orm_single_em_default_table_options', ['YamlBundle', 'AnnotationsBundle', 'XmlBundle', 'AttributesBundle']);
$container = $this->loadContainer('orm_single_em_default_table_options', ['YamlBundle', 'XmlBundle', 'AttributesBundle']);

$param = $container->getDefinition('doctrine.dbal.default_connection')->getArgument(0);

Expand Down
15 changes: 3 additions & 12 deletions tests/DependencyInjection/DoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ public function testOrmMergeConfigs(): void
self::markTestSkipped('This test requires ORM');
}

$container = $this->getContainer(['XmlBundle', 'AnnotationsBundle', 'AttributesBundle']);
$container = $this->getContainer(['XmlBundle', 'AttributesBundle']);
$extension = new DoctrineExtension();

$config1 = BundleConfigurationBuilder::createBuilder()
Expand All @@ -912,10 +912,7 @@ public function testOrmMergeConfigs(): void
'default_entity_manager' => 'default',
'entity_managers' => [
'default' => [
'mappings' => [
'AnnotationsBundle' => [],
'AttributesBundle' => ['type' => 'attribute'],
],
'mappings' => ['AttributesBundle' => ['type' => 'attribute']],
],
],
])
Expand All @@ -938,16 +935,10 @@ public function testOrmMergeConfigs(): 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'),
'Fixtures\Bundles\AnnotationsBundle\Entity',
]);
$this->assertDICDefinitionMethodCallAt(1, $definition, 'addDriver', [
new Reference('doctrine.orm.default_attribute_metadata_driver'),
'Fixtures\Bundles\AttributesBundle\Entity',
]);
$this->assertDICDefinitionMethodCallAt(2, $definition, 'addDriver', [
$this->assertDICDefinitionMethodCallAt(1, $definition, 'addDriver', [
new Reference('doctrine.orm.default_xml_metadata_driver'),
'Fixtures\Bundles\XmlBundle\Entity',
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

<orm default-entity-manager="em2">
<entity-manager name="em1">
<mapping name="AnnotationsBundle" />
<mapping name="AttributesBundle" type="attribute" />
</entity-manager>
<entity-manager name="em2" validate-xml-mapping="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
</dbal>

<orm validate-xml-mapping="true">
<mapping name="AnnotationsBundle" />
<mapping name="AttributesBundle" type="attribute" />
<mapping name="YamlBundle" dir="Resources/config/doctrine" alias="yml" />
<mapping name="manual" type="xml" prefix="Fixtures\Bundles\XmlBundle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
</dbal>

<orm>
<mapping name="AnnotationsBundle" />
<mapping name="AttributesBundle" type="attribute" />
<mapping name="YamlBundle" dir="Resources/config/doctrine" alias="yml" />
<mapping name="manual" type="xml" prefix="Fixtures\Bundles\XmlBundle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ doctrine:
entity_managers:
em1:
mappings:
AnnotationsBundle: ~
AttributesBundle:
type: attribute
em2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ doctrine:
orm:
validate_xml_mapping: true
mappings:
AnnotationsBundle: ~
AttributesBundle:
type: attribute
YamlBundle:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ doctrine:

orm:
mappings:
AnnotationsBundle: ~
AttributesBundle: ~
YamlBundle:
dir: Resources/config/doctrine
Expand Down

0 comments on commit 27cf0be

Please sign in to comment.