From 61e2fcf34e0b12af166e9d86cc0cc20e293b9817 Mon Sep 17 00:00:00 2001 From: Marcelo Jacobus Date: Wed, 13 Jan 2016 15:47:46 +0100 Subject: [PATCH] Attempt to test postgres db --- .travis.yml | 2 +- tests/bootstrap.php | 39 ++++++++++++++++++++++----------------- tests/db_config.php.dist | 10 ++++++---- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 513f202..991b5b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ env: # - DB=sqlite - DB=mysql # - DB=postgresql - # - DB=pg + - DB=pg matrix: fast_finish: true diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 2d705d5..d1c4085 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -6,35 +6,40 @@ $autoloader = require __DIR__ . '/../vendor/autoload.php'; $config = array( - 'driver' => 'mysql', - 'hostname' => 'localhost', - 'database' => 'koine_repository', - 'username' => 'root', - 'password' => '', + 'mysql' => array( + 'driver' => 'mysql', + 'hostname' => 'localhost', + 'database' => 'koine_repository', + 'username' => 'root', + 'password' => '', + ), + 'pg' => array( + 'driver' => 'mysql', + 'hostname' => 'localhost', + 'database' => 'koine_repository', + 'username' => 'postgres', + 'password' => null, + ), ); if (file_exists(__DIR__ . '/db_config.php')) { $config = require __DIR__ . '/db_config.php'; } +$db = getenv('DB'); + +if (!$db) { + $db = 'mysql'; +} + +$config = $config[$db]; + $driver = $config['driver']; $hostname = $config['hostname']; $database = $config['database']; $password = $config['password']; $username = $config['username']; -$db = getenv('DB'); - -if ($db) { - $drivers = array( - 'mysql' => 'mysql', - 'sqlite' => 'sqlite', - 'pg' => 'pgsql', - ); - - $driver = $drivers[$db]; -} - $connection = new PDO("$driver:host=$hostname;", $username, $password); $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); diff --git a/tests/db_config.php.dist b/tests/db_config.php.dist index 20f793d..5693bcb 100644 --- a/tests/db_config.php.dist +++ b/tests/db_config.php.dist @@ -1,8 +1,10 @@ 'localhost', - 'database' => 'koine_repo_test', - 'username' => 'root', - 'password' => '', + 'mysql' => array( + 'hostname' => 'localhost', + 'database' => 'koine_repo_test', + 'username' => 'root', + 'password' => '', + ), );