From c50a58e3b841537fcb2ee11cb641c1346bab876d Mon Sep 17 00:00:00 2001 From: Joe Bennett Date: Mon, 28 Sep 2020 19:44:00 +1000 Subject: [PATCH] #4295 Restored master, slaves, keepReplica params in MasterSlaveConnection --- .../Connections/MasterSlaveConnection.php | 3 -- .../Connections/MasterSlaveConnectionTest.php | 39 +++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 tests/Doctrine/Tests/DBAL/Connections/MasterSlaveConnectionTest.php diff --git a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php index 0e97267643b..984736fd633 100644 --- a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php +++ b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php @@ -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); diff --git a/tests/Doctrine/Tests/DBAL/Connections/MasterSlaveConnectionTest.php b/tests/Doctrine/Tests/DBAL/Connections/MasterSlaveConnectionTest.php new file mode 100644 index 00000000000..c29b8b05a40 --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Connections/MasterSlaveConnectionTest.php @@ -0,0 +1,39 @@ + '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]); + } + } +}