Skip to content

Commit

Permalink
Fix TestEnv
Browse files Browse the repository at this point in the history
  • Loading branch information
ngyuki committed Jul 27, 2018
1 parent 96469a2 commit 3a5c6a4
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions tests/TestHelper/TestEnv.php
Expand Up @@ -2,6 +2,7 @@
namespace TestHelper;

use ngyuki\DbMigrate\Adapter\PdoMySqlAdapter;
use ngyuki\DbMigrate\Console\Configure;
use ngyuki\DbMigrate\Migrate\Config;
use ngyuki\DbMigrate\Migrate\MigrateContext;
use PDO;
Expand Down Expand Up @@ -49,21 +50,14 @@ public function versions()
->fetchAll(PDO::FETCH_COLUMN);
}

/**
* @return PDO
*/
public function pdo()
{
if (self::$pdo === null) {
$host = getenv('MYSQL_HOST');
$port = getenv('MYSQL_PORT');
$name = getenv('MYSQL_DATABASE');
$user = getenv('MYSQL_USER');
$pass = getenv('MYSQL_PASSWORD');

$dsn = sprintf("mysql:dbname=$name;host=$host;port=$port;charset=utf8");

self::$pdo = new PDO($dsn, $user, $pass, array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
));
$config = (new Configure)->get();
self::$pdo = $config['pdo'];
}

return self::$pdo;
Expand Down

0 comments on commit 3a5c6a4

Please sign in to comment.