Skip to content

Instantly share code, notes, and snippets.

@andriesss
Created February 22, 2019 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andriesss/3896134f4c1b2c3e05188940d51e4f6b to your computer and use it in GitHub Desktop.
Save andriesss/3896134f4c1b2c3e05188940d51e4f6b to your computer and use it in GitHub Desktop.
2409.patch
Index: tests/Doctrine/Tests/DBAL/Connections/MasterSlaveConnectionTest.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- tests/Doctrine/Tests/DBAL/Connections/MasterSlaveConnectionTest.php (date 1550843977000)
+++ tests/Doctrine/Tests/DBAL/Connections/MasterSlaveConnectionTest.php (date 1550843977000)
@@ -0,0 +1,53 @@
+<?php
+
+namespace Doctrine\Tests\DBAL\Connections;
+
+use Doctrine\DBAL\Exception\ConnectionException;
+use Doctrine\DBAL\Connections\MasterSlaveConnection;
+use Doctrine\DBAL\DriverManager;
+use Doctrine\Tests\DbalTestCase;
+
+class MasterSlaveConnectionTest extends DbalTestCase
+{
+ public function testConnectionIsMadeToDetectServerVersionWhenVersionIsNotConfigured(): void
+ {
+ $params = [
+ 'driver' => 'pdo_mysql',
+ 'host' => 'localhost',
+ 'user' => 'root',
+ 'password' => 'password',
+ 'port' => '1234',
+ 'master' => ['host' => 'localhost'],
+ 'slaves' => [['host' => 'localhost']],
+ 'wrapperClass' => MasterSlaveConnection::class
+ ];
+
+ $connection = DriverManager::getConnection($params);
+
+ // there is probably a better way to test this, but for now assuming that it simply will not be able
+ // to connect to a non existing connection
+ $this->expectException(ConnectionException::class);
+ $connection->getDatabasePlatform();
+ }
+
+ public function testDatabasePlatformCanBeExtractedWithoutConnection(): void
+ {
+ $params = [
+ 'driver' => 'pdo_mysql',
+ 'host' => 'localhost',
+ 'user' => 'root',
+ 'password' => 'password',
+ 'port' => '1234',
+ 'serverVersion' => '5.6.40',
+ 'master' => ['host' => 'localhost'],
+ 'slaves' => [['host' => 'localhost']],
+ 'wrapperClass' => MasterSlaveConnection::class
+ ];
+
+ $connection = DriverManager::getConnection($params);
+
+ /** @var \Doctrine\DBAL\Platforms\MySqlPlatform $platform */
+ $platform = $connection->getDatabasePlatform();
+ $this->assertInstanceOf(\Doctrine\DBAL\Platforms\MySqlPlatform::class, $platform);
+ }
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment