|
19 | 19 | use Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity\DummyWithProperty; |
20 | 20 | use Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity\DummyWithStringableGetter; |
21 | 21 | use Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity\StringableAddress; |
| 22 | +use Composer\InstalledVersions; |
22 | 23 | use Doctrine\Bundle\DoctrineBundle\ConnectionFactory; |
23 | 24 | use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; |
24 | | -use Doctrine\ORM\Configuration; |
25 | 25 | use Doctrine\ORM\Tools\SchemaTool; |
26 | 26 | use Nyholm\BundleTest\TestKernel; |
27 | | -use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver; |
28 | 27 | use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; |
29 | 28 | use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
30 | 29 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
31 | 30 | use Symfony\Component\HttpClient\MockHttpClient; |
32 | 31 | use Symfony\Component\HttpClient\Response\MockResponse; |
33 | | -use Symfony\Component\HttpKernel\Kernel; |
34 | 32 | use Symfony\Component\HttpKernel\KernelInterface; |
35 | 33 |
|
36 | 34 | /** |
@@ -69,29 +67,30 @@ public function process(ContainerBuilder $container): void |
69 | 67 | }); |
70 | 68 | if (defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP')) { |
71 | 69 | $kernel->addTestConfig(static function (ContainerBuilder $container) { |
72 | | - $container->prependExtensionConfig('doctrine', [ |
73 | | - 'orm' => [ |
74 | | - //'report_fields_where_declared' => true, |
75 | | - ], |
76 | | - ]); |
77 | 70 |
|
78 | | - if (method_exists(Configuration::class, 'setLazyGhostObjectEnabled') && Kernel::VERSION_ID >= 60100) { |
79 | | - $container->prependExtensionConfig('doctrine', [ |
80 | | - 'orm' => [ |
81 | | - //'enable_lazy_ghost_objects' => true, |
82 | | - ], |
83 | | - ]); |
84 | | - } |
| 71 | + $orm = []; |
| 72 | + |
| 73 | + // doctrine-bundle |
| 74 | + if (null !== $doctrineBundleVersion = InstalledVersions::getVersion('doctrine/doctrine-bundle')) { |
| 75 | + // v2 |
| 76 | + if (version_compare($doctrineBundleVersion, '3.0.0', '<')) { |
| 77 | + $orm['auto_generate_proxy_classes'] = true; |
| 78 | + $orm['report_fields_where_declared'] = true; |
| 79 | + $orm['controller_resolver']['auto_mapping'] = true; |
| 80 | + } |
85 | 81 |
|
86 | | - if (class_exists(EntityValueResolver::class)) { |
87 | | - $container->prependExtensionConfig('doctrine', [ |
88 | | - 'orm' => [ |
89 | | - 'controller_resolver' => [ |
90 | | - //'auto_mapping' => false, |
91 | | - ], |
92 | | - ], |
93 | | - ]); |
| 82 | + if (version_compare($doctrineBundleVersion, '2.8.0', '>=') && version_compare($doctrineBundleVersion, '3.0.0', '<')) { |
| 83 | + $orm['enable_lazy_ghost_objects'] = true; |
| 84 | + } |
| 85 | + |
| 86 | + if (\PHP_VERSION_ID >= 80400 && version_compare($doctrineBundleVersion, '2.15.0', '>=') && version_compare($doctrineBundleVersion, '3.1.0', '<')) { |
| 87 | + $orm['enable_native_lazy_objects'] = true; |
| 88 | + } |
94 | 89 | } |
| 90 | + |
| 91 | + $container->prependExtensionConfig('doctrine', [ |
| 92 | + 'orm' => $orm, |
| 93 | + ]); |
95 | 94 | }); |
96 | 95 | } |
97 | 96 | $kernel->handleOptions($options); |
|
0 commit comments