Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4295 Keep master, slaves, keepReplica params in MasterSlaveConnection #4308

Merged
merged 1 commit into from
Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,18 @@ public function __construct(
$this->deprecated('Params key "master"', '"primary"');

$params['primary'] = $params['master'];
unset($params['master']);
}

if (isset($params['slaves'])) {
$this->deprecated('Params key "slaves"', '"replica"');

$params['replica'] = $params['slaves'];
unset($params['slaves']);
}

if (isset($params['keepSlave'])) {
$this->deprecated('Params key "keepSlave"', '"keepReplica"');

$params['keepReplica'] = $params['keepSlave'];
unset($params['keepSlave']);
}

parent::__construct($params, $driver, $config, $eventManager);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Doctrine\Tests\DBAL\Connections;

use Doctrine\DBAL\Connections\MasterSlaveConnection;
use Doctrine\DBAL\Driver;
use Doctrine\Tests\DbalTestCase;

class MasterSlaveConnectionTest extends DbalTestCase
{
public function testConnectionParamsRemainAvailable(): void
{
$constructionParams = [
'driver' => 'pdo_mysql',
'keepSlave' => true,
'master' => [
'host' => 'master.host',
'user' => 'root',
'password' => 'password',
'port' => '1234',
],
'slaves' => [
[
'host' => 'slave1.host',
'user' => 'root',
'password' => 'password',
'port' => '1234',
],
],
];

$connection = new MasterSlaveConnection($constructionParams, $this->createStub(Driver::class));

$connectionParams = $connection->getParams();
foreach ($constructionParams as $key => $value) {
self::assertSame($value, $connectionParams[$key]);
}
greg0ire marked this conversation as resolved.
Show resolved Hide resolved
}
}