Skip to content

Commit f3ca492

Browse files
committed
bug #39401 [DoctrineBridge] no-op RegisterUidTypePass if DBAL types aren't loaded (craue)
This PR was squashed before being merged into the 5.2 branch. Discussion ---------- [DoctrineBridge] no-op RegisterUidTypePass if DBAL types aren't loaded | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #39400 | License | MIT Commits ------- 765ae9e16c [DoctrineBridge] no-op RegisterUidTypePass if DBAL types aren't loaded
2 parents 25b86fc + d751daa commit f3ca492

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

DependencyInjection/CompilerPass/RegisterUidTypePass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ public function process(ContainerBuilder $container)
2828
return;
2929
}
3030

31+
if (!$container->hasParameter('doctrine.dbal.connection_factory.types')) {
32+
return;
33+
}
34+
3135
$typeDefinition = $container->getParameter('doctrine.dbal.connection_factory.types');
3236

3337
if (!isset($typeDefinition['uuid'])) {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection\CompilerPass;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterUidTypePass;
7+
use Symfony\Bridge\Doctrine\Types\UlidType;
8+
use Symfony\Bridge\Doctrine\Types\UuidType;
9+
use Symfony\Component\DependencyInjection\ContainerBuilder;
10+
11+
class RegisterUidTypePassTest extends TestCase
12+
{
13+
public function testRegistered()
14+
{
15+
$container = new ContainerBuilder();
16+
$container->setParameter('doctrine.dbal.connection_factory.types', ['foo' => 'bar']);
17+
(new RegisterUidTypePass())->process($container);
18+
19+
$expected = [
20+
'foo' => 'bar',
21+
'uuid' => ['class' => UuidType::class],
22+
'ulid' => ['class' => UlidType::class],
23+
];
24+
$this->assertSame($expected, $container->getParameter('doctrine.dbal.connection_factory.types'));
25+
}
26+
27+
public function testRegisteredDontFail()
28+
{
29+
$container = new ContainerBuilder();
30+
(new RegisterUidTypePass())->process($container);
31+
32+
$this->expectNotToPerformAssertions();
33+
}
34+
}

0 commit comments

Comments
 (0)