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 CI when testing with Symfony 5.1 #1160

Merged
merged 1 commit into from May 4, 2020
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
26 changes: 25 additions & 1 deletion DependencyInjection/Configuration.php
Expand Up @@ -4,6 +4,7 @@

use Doctrine\ORM\EntityManager;
use ReflectionClass;
use Symfony\Component\Config\Definition\BaseNode;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
Expand Down Expand Up @@ -91,7 +92,7 @@ private function addDbalSection(ArrayNodeDefinition $node) : void
->end()
->children()
->scalarNode('class')->isRequired()->end()
->booleanNode('commented')->setDeprecated()->end()
->booleanNode('commented')->setDeprecated(...$this->getCommentedParamDeprecationMsg())->end()
->end()
->end()
->end()
Expand Down Expand Up @@ -685,4 +686,27 @@ private function getAutoGenerateModes() : array
'values' => $valuesArray,
];
}

/**
* Returns the correct deprecation param's as an array for setDeprecated.
*
* Symfony/Config v5.1 introduces a deprecation notice when calling
* setDeprecation() with less than 3 args and the getDeprecation method was
* introduced at the same time. By checking if getDeprecation() exists,
* we can determine the correct param count to use when calling setDeprecated.
*/
private function getCommentedParamDeprecationMsg() : array
{
$message = 'The doctrine-bundle type commenting features were removed; the corresponding config parameter was deprecated in 2.0 and will be dropped in 3.0.';

if (method_exists(BaseNode::class, 'getDeprecation')) {
return [
'doctrine/doctrine-bundle',
'2.0',
$message,
];
}

return [$message];
}
}
5 changes: 2 additions & 3 deletions Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
Expand Up @@ -643,8 +643,7 @@ public function testResolveTargetEntity() : void

$definition = $container->getDefinition('doctrine.orm.listeners.resolve_target_entity');
$this->assertDICDefinitionMethodCallOnce($definition, 'addResolveTargetEntity', ['Symfony\Component\Security\Core\User\UserInterface', 'MyUserClass', []]);

$this->assertEquals(['doctrine.event_subscriber' => [[]]], $definition->getTags());
$this->assertSame([ [] ], $definition->getTags()['doctrine.event_subscriber']);
}

public function testAttachEntityListeners() : void
Expand All @@ -655,7 +654,7 @@ public function testAttachEntityListeners() : void
$methodCalls = $definition->getMethodCalls();

$this->assertDICDefinitionMethodCallCount($definition, 'addEntityListener', [], 6);
$this->assertEquals(['doctrine.event_listener' => [ ['event' => 'loadClassMetadata'] ] ], $definition->getTags());
$this->assertSame([ ['event' => 'loadClassMetadata'] ], $definition->getTags()['doctrine.event_listener']);

$this->assertEquals($methodCalls[0], [
'addEntityListener',
Expand Down