function UnitTestCase::setUp
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::setUp()
- 10 core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::setUp()
- 9 core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::setUp()
- 8.9.x core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::setUp()
138 methods override UnitTestCase::setUp()
- ActiveWorkspaceCheckTest::setUp in core/
modules/ workspaces/ tests/ src/ Unit/ ActiveWorkspaceCheckTest.php - AliasManagerTest::setUp in core/
modules/ path_alias/ tests/ src/ Unit/ AliasManagerTest.php - AliasPathProcessorTest::setUp in core/
modules/ path_alias/ tests/ src/ Unit/ PathProcessor/ AliasPathProcessorTest.php - AllowToolbarPathTest::setUp in core/
modules/ toolbar/ tests/ src/ Unit/ PageCache/ AllowToolbarPathTest.php - AnnounceFetcherUnitTest::setUp in core/
modules/ announcements_feed/ tests/ src/ Unit/ AnnounceFetcherUnitTest.php
File
-
core/
tests/ Drupal/ Tests/ UnitTestCase.php, line 65
Class
- UnitTestCase
- Provides a base class and helpers for Drupal unit tests.
Namespace
Drupal\TestsCode
protected function setUp() : void {
parent::setUp();
// Ensure that an instantiated container in the global state of \Drupal from
// a previous test does not leak into this test.
\Drupal::unsetContainer();
// Ensure that the NullFileCache implementation is used for the FileCache as
// unit tests should not be relying on caches implicitly.
FileCacheFactory::setConfiguration([
FileCacheFactory::DISABLE_CACHE => TRUE,
]);
// Ensure that FileCacheFactory has a prefix.
FileCacheFactory::setPrefix('prefix');
$this->root = dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)), 2);
chdir($this->root);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.