Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests by adjusting switch for enabling annotations #1734

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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