1
0
mirror of synced 2024-12-14 07:06:04 +03:00
doctrine2/tests/Doctrine/Tests/TestUtil.php

33 lines
1.0 KiB
PHP
Raw Normal View History

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