Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mjacobus committed Jan 13, 2016
1 parent 00af044 commit ef988fb
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 27 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ sudo: false
language: php

env:
- DB=sqlite
# - DB=sqlite
- DB=mysql
# - DB=postgresql
- DB=pg
# - DB=pg

matrix:
fast_finish: true
Expand All @@ -27,10 +27,10 @@ install:
- travis_retry composer install --no-interaction --ignore-platform-reqs

script:
- ./vendor/bin/phpunit --version
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then vendor/bin/phpunit ; fi
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then vendor/bin/phpunit --coverage-clover=./build/logs/clover.xml; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./bin/php-cs-fix.sh src true ; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./bin/php-cs-fix.sh tests true ; fi
# - if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./bin/php-cs-fix.sh src true ; fi

after_script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls ; fi
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"zendframework/zend-hydrator": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "*",
"phpunit/phpunit": "~4.6",
"satooshi/php-coveralls": "^1.0",
"zendframework/zend-eventmanager": "^2.5.1",
"zendframework/zend-inputfilter": "^2.5.1",
Expand Down
45 changes: 27 additions & 18 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,47 @@
$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);
$connection->exec('SET CHARACTER SET utf8');

try {
$connection->exec('SET CHARACTER SET utf8');
} catch (\PDOException $e) {
}

$testTable = <<<SQL
CREATE TABLE `test_table` (
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 ef988fb

Please sign in to comment.