Skip to content

Commit

Permalink
doctrine#4295 Restored master, slaves, keepReplica params in MasterSl…
Browse files Browse the repository at this point in the history
…aveConnection
  • Loading branch information
Joe Bennett committed Sep 27, 2020
1 parent 1687865 commit f0b9b39
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
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,43 @@
<?php

namespace Doctrine\Tests\DBAL\Connections;

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

class MasterSlaveConnectionTest extends DbalTestCase
{
/**
* \Doctrine\DBAL\Connection::getParams has been marked @internal as of 2.11.0
* This test will be removed in 3.0
*/
public function testConnectionDoesParamsRemainAvailable(): 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->createMock(Driver::class));

$connectionParams = $connection->getParams();
foreach ($constructionParams as $key => $value) {
self::assertSame($constructionParams[$key], $value);
}
}
}

0 comments on commit f0b9b39

Please sign in to comment.