Skip to content

Commit

Permalink
Prefer ChildDefinition as soon as possible
Browse files Browse the repository at this point in the history
This fixes a deprecation triggered while running tests.
  • Loading branch information
greg0ire authored and soullivaneuh committed Nov 7, 2017
1 parent 4e2d380 commit faa11de
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PHPUnit\Framework\TestCase;
use Sonata\AdminBundle\DependencyInjection\Compiler\AddDependencyCallsCompilerPass;
use Sonata\AdminBundle\DependencyInjection\SonataAdminExtension;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;

Expand Down Expand Up @@ -479,13 +480,19 @@ public function testProcessAbstractAdminServiceInServiceDefinition()
->setArguments(['', 'Sonata\AdminBundle\Tests\DependencyInjection\Post', ''])
->setAbstract(true);

$adminDefinition = new DefinitionDecorator('sonata_abstract_post_admin');
// NEXT_MAJOR: Simplify this when dropping sf < 3.3
$adminDefinition = class_exists(ChildDefinition::class) ?
new ChildDefinition('sonata_abstract_post_admin') :
new DefinitionDecorator('sonata_abstract_post_admin');
$adminDefinition
->setClass('Sonata\AdminBundle\Tests\DependencyInjection\MockAbstractServiceAdmin')
->setArguments([0 => 'extra_argument_1'])
->addTag('sonata.admin', ['group' => 'sonata_post_one_group', 'manager_type' => 'orm']);

$adminTwoDefinition = new DefinitionDecorator('sonata_abstract_post_admin');
// NEXT_MAJOR: Simplify this when dropping sf < 3.3
$adminTwoDefinition = class_exists(ChildDefinition::class) ?
new ChildDefinition('sonata_abstract_post_admin') :
new DefinitionDecorator('sonata_abstract_post_admin');
$adminTwoDefinition
->setClass('Sonata\AdminBundle\Tests\DependencyInjection\MockAbstractServiceAdmin')
->setArguments([0 => 'extra_argument_2', 'index_0' => 'should_not_override'])
Expand Down

0 comments on commit faa11de

Please sign in to comment.