Issue #2171315 by diarmy, tim.plunkett: Cleanup the container in UnitTestCase::tearDown.
parent
9de7379123
commit
c07a96e61c
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue