Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
dcdf744e
Commit
dcdf744e
authored
Jan 18, 2015
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initialize database schema only once per phpunit run
parent
dfb44bda
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
TestUtil.php
tests/Doctrine/Tests/TestUtil.php
+21
-14
No files found.
tests/Doctrine/Tests/TestUtil.php
View file @
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
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment