Skip to content

Commit

Permalink
Attempt to test postgres db
Browse files Browse the repository at this point in the history
  • Loading branch information
mjacobus committed Jan 13, 2016
1 parent 5586c58 commit 61e2fcf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ env:
# - DB=sqlite
- DB=mysql
# - DB=postgresql
# - DB=pg
- DB=pg

matrix:
fast_finish: true
Expand Down
39 changes: 22 additions & 17 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
10 changes: 6 additions & 4 deletions tests/db_config.php.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

return array(
'hostname' => 'localhost',
'database' => 'koine_repo_test',
'username' => 'root',
'password' => '',
'mysql' => array(
'hostname' => 'localhost',
'database' => 'koine_repo_test',
'username' => 'root',
'password' => '',
),
);

0 comments on commit 61e2fcf

Please sign in to comment.