diff --git a/tests/Doctrine/EntityRegeneratorTest.php b/tests/Doctrine/EntityRegeneratorTest.php index 0062386ba..58b6078f8 100644 --- a/tests/Doctrine/EntityRegeneratorTest.php +++ b/tests/Doctrine/EntityRegeneratorTest.php @@ -12,6 +12,7 @@ namespace Symfony\Bundle\MakerBundle\Tests\Doctrine; use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; +use Doctrine\Persistence\Reflection\RuntimeReflectionProperty; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; @@ -166,19 +167,26 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load 'url' => 'sqlite:///fake', ]; - $c->prependExtensionConfig('doctrine', [ - 'dbal' => $dbal, - 'orm' => [ - 'mappings' => [ - 'EntityRegenerator' => [ - 'is_bundle' => false, - 'dir' => '%kernel.project_dir%/src/Entity', - 'prefix' => 'Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity', - 'alias' => 'EntityRegeneratorApp', - 'type' => 'attribute', - ], + $orm = [ + 'mappings' => [ + 'EntityRegenerator' => [ + 'is_bundle' => false, + 'dir' => '%kernel.project_dir%/src/Entity', + 'prefix' => 'Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity', + 'alias' => 'EntityRegeneratorApp', + 'type' => 'attribute', ], ], + ]; + + /* @legacy Remove conditional when doctrine/persistence <3.1 are no longer supported. */ + if (class_exists(RuntimeReflectionProperty::class)) { + $orm['enable_lazy_ghost_objects'] = true; + } + + $c->prependExtensionConfig('doctrine', [ + 'dbal' => $dbal, + 'orm' => $orm, ]); } @@ -219,20 +227,27 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load 'url' => 'sqlite:///fake', ]; - $c->prependExtensionConfig('doctrine', [ - 'dbal' => $dbal, - 'orm' => [ - 'auto_generate_proxy_classes' => true, - 'mappings' => [ - 'EntityRegenerator' => [ - 'is_bundle' => false, - 'type' => 'xml', - 'dir' => '%kernel.project_dir%/config/doctrine', - 'prefix' => 'Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity', - 'alias' => 'EntityRegeneratorApp', - ], + $orm = [ + 'auto_generate_proxy_classes' => true, + 'mappings' => [ + 'EntityRegenerator' => [ + 'is_bundle' => false, + 'type' => 'xml', + 'dir' => '%kernel.project_dir%/config/doctrine', + 'prefix' => 'Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity', + 'alias' => 'EntityRegeneratorApp', ], ], + ]; + + /* @legacy Remove conditional when doctrine/persistence <3.1 are no longer supported. */ + if (class_exists(RuntimeReflectionProperty::class)) { + $orm['enable_lazy_ghost_objects'] = true; + } + + $c->prependExtensionConfig('doctrine', [ + 'dbal' => $dbal, + 'orm' => $orm, ]); }