Skip to content

Commit f8bdb78

Browse files
committed
feat: allow doctrine/doctrine-bundle 3
1 parent c763970 commit f8bdb78

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

tests/Functional/GeocoderListenerTest.php

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,16 @@
1919
use Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity\DummyWithProperty;
2020
use Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity\DummyWithStringableGetter;
2121
use Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity\StringableAddress;
22+
use Composer\InstalledVersions;
2223
use Doctrine\Bundle\DoctrineBundle\ConnectionFactory;
2324
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
24-
use Doctrine\ORM\Configuration;
2525
use Doctrine\ORM\Tools\SchemaTool;
2626
use Nyholm\BundleTest\TestKernel;
27-
use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver;
2827
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
2928
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
3029
use Symfony\Component\DependencyInjection\ContainerBuilder;
3130
use Symfony\Component\HttpClient\MockHttpClient;
3231
use Symfony\Component\HttpClient\Response\MockResponse;
33-
use Symfony\Component\HttpKernel\Kernel;
3432
use Symfony\Component\HttpKernel\KernelInterface;
3533

3634
/**
@@ -69,29 +67,30 @@ public function process(ContainerBuilder $container): void
6967
});
7068
if (defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP')) {
7169
$kernel->addTestConfig(static function (ContainerBuilder $container) {
72-
$container->prependExtensionConfig('doctrine', [
73-
'orm' => [
74-
//'report_fields_where_declared' => true,
75-
],
76-
]);
7770

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+
}
8581

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+
}
9489
}
90+
91+
$container->prependExtensionConfig('doctrine', [
92+
'orm' => $orm,
93+
]);
9594
});
9695
}
9796
$kernel->handleOptions($options);

0 commit comments

Comments
 (0)