diff --git a/core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryTest.php b/core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryTest.php index 85c6f010f3..e2de5ca210 100644 --- a/core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryTest.php +++ b/core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryTest.php @@ -14,18 +14,34 @@ class AnnotatedClassDiscoveryTest extends TestCase { /** + * Original file cache configuration from before we disable it. + * + * @var array + */ + protected $originalFileCacheConfig; + + /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); // Ensure that the NullFileCache implementation is used for the FileCache as // unit tests should not be relying on caches implicitly. + $this->originalFileCacheConfig = FileCacheFactory::getConfiguration(); FileCacheFactory::setConfiguration([FileCacheFactory::DISABLE_CACHE => TRUE]); // Ensure that FileCacheFactory has a prefix. FileCacheFactory::setPrefix('prefix'); } /** + * {@inheritdoc} + */ + protected function tearDown() { + FileCacheFactory::setConfiguration($this->originalFileCacheConfig); + parent::tearDown(); + } + + /** * @covers ::__construct * @covers ::getPluginNamespaces */ diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php index 5139f97730..032b8c7e9d 100644 --- a/core/tests/Drupal/Tests/UnitTestCase.php +++ b/core/tests/Drupal/Tests/UnitTestCase.php @@ -33,6 +33,13 @@ protected $root; /** + * Original file cache configuration from before we disable it. + * + * @var array + */ + protected $originalFileCacheConfig; + + /** * {@inheritdoc} */ protected function setUp() { @@ -43,6 +50,7 @@ protected function setUp() { // Ensure that the NullFileCache implementation is used for the FileCache as // unit tests should not be relying on caches implicitly. + $this->originalFileCacheConfig = FileCacheFactory::getConfiguration(); FileCacheFactory::setConfiguration([FileCacheFactory::DISABLE_CACHE => TRUE]); // Ensure that FileCacheFactory has a prefix. FileCacheFactory::setPrefix('prefix'); @@ -51,6 +59,14 @@ protected function setUp() { } /** + * {@inheritdoc} + */ + protected function tearDown() { + FileCacheFactory::setConfiguration($this->originalFileCacheConfig); + parent::tearDown(); + } + + /** * Generates a unique random string containing letters and numbers. * * @param int $length