Issue #2171315 by diarmy, tim.plunkett: Cleanup the container in UnitTestCase::tearDown.

8.0.x
webchick 2014-01-23 22:19:50 -08:00
parent 9de7379123
commit c07a96e61c
4 changed files with 12 additions and 24 deletions

View File

@ -74,15 +74,6 @@ class CommentLockTest extends UnitTestCase {
$comment->postSave($storage_controller);
}
/**
* {@inheritdoc}
*/
protected function tearDown() {
parent::tearDown();
$container = new ContainerBuilder();
\Drupal::setContainer($container);
}
}
}
namespace {

View File

@ -46,12 +46,6 @@ abstract class LocalTaskIntegrationTest extends UnitTestCase {
\Drupal::setContainer($container);
}
protected function tearDown() {
// Passes in an empty container.
$container = new ContainerBuilder();
\Drupal::setContainer($container);
}
/**
* Sets up the local task manager for the test.
*/

View File

@ -119,15 +119,6 @@ class UserSessionTest extends UnitTestCase {
$this->users['user_last'] = $this->createUserSession();
}
/**
* {@inheritdoc}
*/
protected function tearDown() {
parent::tearDown();
$container = new ContainerBuilder();
\Drupal::setContainer($container);
}
/**
* Tests the has permission method.
*

View File

@ -8,6 +8,7 @@
namespace Drupal\Tests;
use Drupal\Component\Utility\Random;
use Drupal\Core\DependencyInjection\ContainerBuilder;
/**
* Provides a base class and helpers for Drupal unit tests.
@ -40,6 +41,17 @@ abstract class UnitTestCase extends \PHPUnit_Framework_TestCase {
throw new \RuntimeException("Sub-class must implement the getInfo method!");
}
/**
* {@inheritdoc}
*/
protected function tearDown() {
parent::tearDown();
if (\Drupal::getContainer()) {
$container = new ContainerBuilder();
\Drupal::setContainer($container);
}
}
/**
* Generates a unique random string containing letters and numbers.
*