Add the possibility to specify driver options in test configuration

parent 76564ab8
...@@ -30,8 +30,9 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase ...@@ -30,8 +30,9 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase
$user = $params['user'] ?? null; $user = $params['user'] ?? null;
$password = $params['password'] ?? null; $password = $params['password'] ?? null;
$driverOptions = $params['driverOptions'] ?? [];
$connection = $this->driver->connect($params, $user, $password); $connection = $this->driver->connect($params, $user, $password, $driverOptions);
self::assertInstanceOf(DriverConnection::class, $connection); self::assertInstanceOf(DriverConnection::class, $connection);
} }
......
...@@ -8,6 +8,8 @@ use Doctrine\DBAL\Driver\Mysqli\MysqliException; ...@@ -8,6 +8,8 @@ use Doctrine\DBAL\Driver\Mysqli\MysqliException;
use Doctrine\Tests\DbalFunctionalTestCase; use Doctrine\Tests\DbalFunctionalTestCase;
use Doctrine\Tests\TestUtil; use Doctrine\Tests\TestUtil;
use function array_merge;
use const MYSQLI_OPT_CONNECT_TIMEOUT; use const MYSQLI_OPT_CONNECT_TIMEOUT;
/** /**
...@@ -54,6 +56,10 @@ class ConnectionTest extends DbalFunctionalTestCase ...@@ -54,6 +56,10 @@ class ConnectionTest extends DbalFunctionalTestCase
{ {
$params = TestUtil::getConnectionParams(); $params = TestUtil::getConnectionParams();
if (isset($params['driverOptions'])) {
$driverOptions = array_merge($params['driverOptions'], $driverOptions);
}
return new MysqliConnection( return new MysqliConnection(
$params, $params,
$params['user'] ?? '', $params['user'] ?? '',
......
...@@ -9,6 +9,8 @@ use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; ...@@ -9,6 +9,8 @@ use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use Doctrine\Tests\TestUtil; use Doctrine\Tests\TestUtil;
use PDO; use PDO;
use function array_merge;
/** /**
* @requires extension pdo_sqlsrv * @requires extension pdo_sqlsrv
*/ */
...@@ -42,6 +44,10 @@ class DriverTest extends AbstractDriverTest ...@@ -42,6 +44,10 @@ class DriverTest extends AbstractDriverTest
{ {
$params = TestUtil::getConnectionParams(); $params = TestUtil::getConnectionParams();
if (isset($params['driverOptions'])) {
$driverOptions = array_merge($params['driverOptions'], $driverOptions);
}
return $this->connection->getDriver()->connect( return $this->connection->getDriver()->connect(
$params, $params,
$params['user'] ?? '', $params['user'] ?? '',
......
...@@ -116,8 +116,9 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase ...@@ -116,8 +116,9 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$user = $params['user'] ?? null; $user = $params['user'] ?? null;
$password = $params['password'] ?? null; $password = $params['password'] ?? null;
$driverOptions = $params['driverOptions'] ?? [];
$connection = $this->connection->getDriver()->connect($params, $user, $password); $connection = $this->connection->getDriver()->connect($params, $user, $password, $driverOptions);
self::assertInstanceOf(Connection::class, $connection); self::assertInstanceOf(Connection::class, $connection);
......
...@@ -45,8 +45,9 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -45,8 +45,9 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
$user = $params['user'] ?? null; $user = $params['user'] ?? null;
$password = $params['password'] ?? null; $password = $params['password'] ?? null;
$driverOptions = $params['driverOptions'] ?? [];
$connection = $this->connection->getDriver()->connect($params, $user, $password); $connection = $this->connection->getDriver()->connect($params, $user, $password, $driverOptions);
self::assertInstanceOf(Connection::class, $connection); self::assertInstanceOf(Connection::class, $connection);
......
...@@ -8,6 +8,9 @@ use PHPUnit\Framework\Assert; ...@@ -8,6 +8,9 @@ use PHPUnit\Framework\Assert;
use function explode; use function explode;
use function extension_loaded; use function extension_loaded;
use function strlen;
use function strpos;
use function substr;
use function unlink; use function unlink;
/** /**
...@@ -190,6 +193,14 @@ class TestUtil ...@@ -190,6 +193,14 @@ class TestUtil
$parameters[$parameter] = $configuration[$prefix . $parameter]; $parameters[$parameter] = $configuration[$prefix . $parameter];
} }
foreach ($configuration as $param => $value) {
if (strpos($param, $prefix . 'driver_option_') !== 0) {
continue;
}
$parameters['driverOptions'][substr($param, strlen($prefix . 'driver_option_'))] = $value;
}
return $parameters; return $parameters;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment