Commit 170817a8 authored by Marco Pivetta's avatar Marco Pivetta

Merge pull request #779 from deeky666/improve-testsuite-performance

[DBAL-1123] Initialize database schema only once per PHPUnit run
parents dfb44bda dcdf744e
......@@ -12,6 +12,11 @@ use Doctrine\DBAL\DriverManager;
*/
class TestUtil
{
/**
* @var boolean Whether the database schema is initialized.
*/
private static $initialized = false;
/**
* Gets a <b>real</b> database connection using the following parameters
* of the $GLOBALS array:
......@@ -29,9 +34,7 @@ class TestUtil
* on an XML configuration file. If no such parameters exist, an SQLite
* in-memory database is used.
*
* IMPORTANT:
* 1) Each invocation of this method returns a NEW database connection.
* 2) The database is dropped and recreated to ensure it's clean.
* IMPORTANT: Each invocation of this method returns a NEW database connection.
*
* @return Connection The database connection instance.
*/
......@@ -82,6 +85,7 @@ class TestUtil
$platform = $tmpConn->getDatabasePlatform();
if (! self::$initialized) {
if ($platform->supportsCreateDropDatabase()) {
$dbname = $realConn->getDatabase();
$realConn->close();
......@@ -100,6 +104,9 @@ class TestUtil
}
}
self::$initialized = true;
}
return $realDbParams;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment