Skip to content

Commit

Permalink
Fix doctrine#1314, shard manager class option cannot be overridden
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberemissary committed Mar 29, 2021
1 parent 70be9d4 commit ee29309
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions DependencyInjection/DoctrineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ protected function getConnectionOptions($connection)
'profiling' => true,
'mapping_types' => true,
'platform_service' => true,
'shardManagerClass' => true,
];
foreach ($options as $key => $value) {
if (isset($nonRewrittenKeys[$key])) {
Expand Down
14 changes: 14 additions & 0 deletions Tests/DependencyInjection/DoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@ public function testShardManager(): void
{
$container = $this->getContainer();
$extension = new DoctrineExtension();
$managerClass = 'Fake\\ShardManager';

$config = BundleConfigurationBuilder::createBuilder()
->addConnection([
Expand All @@ -987,6 +988,12 @@ public function testShardManager(): void
],
],
'bar' => [],
'baz' => [
'shards' => [
'test' => ['id' => 1],
],
'shard_manager_class' => $managerClass
]
],
])
->build();
Expand All @@ -995,6 +1002,13 @@ public function testShardManager(): void

$this->assertTrue($container->hasDefinition('doctrine.dbal.foo_shard_manager'));
$this->assertFalse($container->hasDefinition('doctrine.dbal.bar_shard_manager'));
$this->assertTrue($container->hasDefinition('doctrine.dbal.baz_shard_manager'));

$fooManagerDef = $container->getDefinition('doctrine.dbal.foo_shard_manager');
$bazManagerDef = $container->getDefinition('doctrine.dbal.baz_shard_manager');

$this->assertEquals('Doctrine\\DBAL\\Sharding\\PoolingShardManager', $fooManagerDef->getClass());
$this->assertEquals($managerClass, $bazManagerDef->getClass());
}

private function getContainer($bundles = 'YamlBundle', $vendor = null): ContainerBuilder
Expand Down

0 comments on commit ee29309

Please sign in to comment.