function DrupalTestCaseTrait::setUpRoot

Ensure that the $root property is set initially.

This is run with a high priority since other test setup code that runs in #[Before] hooks or setUp() requires access to $root.

@internal

Attributes

#[Before(100)]

File

core/tests/Drupal/Tests/DrupalTestCaseTrait.php, line 35

Class

DrupalTestCaseTrait
Provides methods common across all Drupal abstract base test classes.

Namespace

Drupal\Tests

Code

final protected function setUpRoot() : void {
  if (isset($this->root)) {
    throw new \LogicException("setUpRoot should be called exactly once by PHPUnit's Before test hook and root overrides should happen after.");
  }
  $this->root = dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)), 2);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.