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; ...@@ -12,6 +12,11 @@ use Doctrine\DBAL\DriverManager;
*/ */
class TestUtil 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 * Gets a <b>real</b> database connection using the following parameters
* of the $GLOBALS array: * of the $GLOBALS array:
...@@ -29,9 +34,7 @@ class TestUtil ...@@ -29,9 +34,7 @@ class TestUtil
* on an XML configuration file. If no such parameters exist, an SQLite * on an XML configuration file. If no such parameters exist, an SQLite
* in-memory database is used. * in-memory database is used.
* *
* IMPORTANT: * IMPORTANT: Each invocation of this method returns a NEW database connection.
* 1) Each invocation of this method returns a NEW database connection.
* 2) The database is dropped and recreated to ensure it's clean.
* *
* @return Connection The database connection instance. * @return Connection The database connection instance.
*/ */
...@@ -82,6 +85,7 @@ class TestUtil ...@@ -82,6 +85,7 @@ class TestUtil
$platform = $tmpConn->getDatabasePlatform(); $platform = $tmpConn->getDatabasePlatform();
if (! self::$initialized) {
if ($platform->supportsCreateDropDatabase()) { if ($platform->supportsCreateDropDatabase()) {
$dbname = $realConn->getDatabase(); $dbname = $realConn->getDatabase();
$realConn->close(); $realConn->close();
...@@ -100,6 +104,9 @@ class TestUtil ...@@ -100,6 +104,9 @@ class TestUtil
} }
} }
self::$initialized = true;
}
return $realDbParams; 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