Skip to content

Commit

Permalink
fix tests by adjusting switch for enabling annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher committed Dec 7, 2023
1 parent 4194459 commit 56fcc08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 6 additions & 5 deletions Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -55,6 +55,7 @@
use function sprintf;
use function sys_get_temp_dir;
use function uniqid;
use function version_compare;

use const DIRECTORY_SEPARATOR;

Expand Down Expand Up @@ -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',
]);

Expand All @@ -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',
] : [],
[
Expand Down Expand Up @@ -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),
Expand All @@ -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'),
Expand Down
5 changes: 2 additions & 3 deletions Tests/DependencyInjection/Fixtures/DbalTestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@

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;
use Symfony\Component\DependencyInjection\ContainerBuilder;
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
{
Expand Down Expand Up @@ -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', '<'),
],
]);

Expand Down

0 comments on commit 56fcc08

Please sign in to comment.