From e6d914cfe18ad1a94a7a9f3e1bbaa5fb7d0245c1 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 18 Apr 2020 14:01:24 +0200 Subject: [PATCH] Ensured mysql config is not loaded for sqlite test envs --- config/autoload/entity-manager.local.php.dist | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/config/autoload/entity-manager.local.php.dist b/config/autoload/entity-manager.local.php.dist index d2fc3fd8..1faed328 100644 --- a/config/autoload/entity-manager.local.php.dist +++ b/config/autoload/entity-manager.local.php.dist @@ -2,6 +2,14 @@ declare(strict_types=1); +use function Shlinkio\Shlink\Common\env; + +// When running tests, any mysql-specific option can interfere with other drivers +$driverOptions = env('APP_ENV') === 'test' ? [] : [ + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', + PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, +]; + return [ 'entity_manager' => [ @@ -10,10 +18,7 @@ return [ 'password' => 'root', 'driver' => 'pdo_mysql', 'host' => 'shlink_db', - 'driverOptions' => [ - PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, - ], + 'driverOptions' => $driverOptions, ], ],