function UnitTestCase::setUp

Same name in other branches
  1. 9 core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::setUp()
  2. 8.9.x core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::setUp()
  3. 10 core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::setUp()
356 calls to UnitTestCase::setUp()
AcceptHeaderMatcherTest::setUp in core/tests/Drupal/Tests/Core/Routing/AcceptHeaderMatcherTest.php
AccessAwareRouterTest::setUp in core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
AccessGroupAndTest::setUp in core/modules/block_content/tests/src/Unit/Access/AccessGroupAndTest.php
AccessManagerTest::setUp in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
AccessPolicyProcessorTest::setUp in core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php

... See full list

356 methods override UnitTestCase::setUp()
AcceptHeaderMatcherTest::setUp in core/tests/Drupal/Tests/Core/Routing/AcceptHeaderMatcherTest.php
AccessAwareRouterTest::setUp in core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
AccessGroupAndTest::setUp in core/modules/block_content/tests/src/Unit/Access/AccessGroupAndTest.php
AccessManagerTest::setUp in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
AccessPolicyProcessorTest::setUp in core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php

... See full list

File

core/tests/Drupal/Tests/UnitTestCase.php, line 56

Class

UnitTestCase
Provides a base class and helpers for Drupal unit tests.

Namespace

Drupal\Tests

Code

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.