2008-02-10 22:08:31 +03:00
|
|
|
<?php
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
namespace Doctrine\Tests;
|
2009-01-04 19:15:32 +03:00
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
class TestUtil
|
2008-02-11 22:56:26 +03:00
|
|
|
{
|
2008-02-10 22:08:31 +03:00
|
|
|
public static function getConnection()
|
|
|
|
{
|
|
|
|
if (isset($GLOBALS['db_type'], $GLOBALS['db_username'], $GLOBALS['db_password'],
|
2009-01-12 16:34:41 +03:00
|
|
|
$GLOBALS['db_host'], $GLOBALS['db_name'], $GLOBALS['db_port'])) {
|
2008-06-15 19:56:28 +04:00
|
|
|
$params = array(
|
|
|
|
'driver' => $GLOBALS['db_type'],
|
|
|
|
'user' => $GLOBALS['db_username'],
|
|
|
|
'password' => $GLOBALS['db_password'],
|
|
|
|
'host' => $GLOBALS['db_host'],
|
2009-01-12 16:34:41 +03:00
|
|
|
'dbname' => $GLOBALS['db_name'],
|
|
|
|
'port' => $GLOBALS['db_port']
|
2008-06-15 19:56:28 +04:00
|
|
|
);
|
2008-02-10 22:08:31 +03:00
|
|
|
} else {
|
2008-06-15 19:56:28 +04:00
|
|
|
$params = array(
|
2008-09-12 21:25:38 +04:00
|
|
|
'driver' => 'pdo_sqlite',
|
2008-07-04 20:32:19 +04:00
|
|
|
'memory' => true
|
2008-06-15 19:56:28 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
return \Doctrine\DBAL\DriverManager::getConnection($params);
|
2008-02-10 22:08:31 +03:00
|
|
|
}
|
|
|
|
}
|