Skip to content

Commit

Permalink
Not dropping the connection for
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Mar 28, 2014
1 parent cb87b2d commit 1159f57
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/TestSuite/Fixture/FixtureInjector.php
Expand Up @@ -36,6 +36,13 @@ class FixtureInjector implements PHPUnit_Framework_TestListener {
*/
protected $_fixtureManager;

/**
* Indicates the current number of nested testsuites
*
* @var integer
*/
protected $_nesting = 0;

/**
* Constructor. Save internally the reference to the passed fixture manager
*
Expand All @@ -53,6 +60,7 @@ public function __construct(FixtureManager $manager) {
* @return void
*/
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
$this->_nesting++;
foreach ($suite->getIterator() as $test) {
if ($test instanceof TestCase) {
$this->_fixtureManager->fixturize($test);
Expand All @@ -69,10 +77,13 @@ public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
* @return void
*/
public function endTestSuite(PHPUnit_Framework_TestSuite $suite) {
$this->_nesting--;
$this->_fixtureManager->shutdown();
$config = ConnectionManager::config('test');
ConnectionManager::drop('test');
ConnectionManager::config('test', $config);
if (!$this->_nesting) {
$config = ConnectionManager::config('test');
ConnectionManager::drop('test');
ConnectionManager::config('test', $config);
}
}

/**
Expand Down

0 comments on commit 1159f57

Please sign in to comment.