Skip to content

Commit

Permalink
A more elegant way to set the test DSN.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/DB/trunk@320825 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Daniel Convissor committed Dec 10, 2011
1 parent 47cc18a commit 881a6f2
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions tests/driver/setup.inc
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,19 @@ $dsns = array(
);

if (!empty($_ENV['MYSQL_TEST_USER'])) {
$dsn = 'mysqli://' . rawurlencode($_ENV['MYSQL_TEST_USER'])
. ':' . rawurlencode($_ENV['MYSQL_TEST_PASSWD']);
if (empty($_ENV['MYSQL_TEST_SOCKET'])) {
$dsn .= '@' . $_ENV['MYSQL_TEST_HOST'];
if (!empty($_ENV['MYSQL_TEST_PORT'])) {
$dsn .= ':' . $_ENV['MYSQL_TEST_PORT'];
}
} else {
$dsn .= '@unix(' . $_ENV['MYSQL_TEST_SOCKET'] . ')';
}
$dsn .= '/' . rawurlencode($_ENV['MYSQL_TEST_DB']);
$dsns['mysqli'] = $dsn;
$dsns['mysqli'] = array(
'phptype' => 'mysqli',
'username' => $_ENV['MYSQL_TEST_USER'],
'password' => $_ENV['MYSQL_TEST_PASSWD'],
'database' => $_ENV['MYSQL_TEST_DB'],

'hostspec' => empty($_ENV['MYSQL_TEST_HOST'])
? null : $_ENV['MYSQL_TEST_HOST'],

'port' => empty($_ENV['MYSQL_TEST_PORT'])
? null : $_ENV['MYSQL_TEST_PORT'],

'socket' => empty($_ENV['MYSQL_TEST_SOCKET'])
? null : $_ENV['MYSQL_TEST_SOCKET'],
);
}

0 comments on commit 881a6f2

Please sign in to comment.