trait TestRequirementsTrait
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/TestRequirementsTrait.php \Drupal\Tests\TestRequirementsTrait
- 10 core/tests/Drupal/Tests/TestRequirementsTrait.php \Drupal\Tests\TestRequirementsTrait
- 9 core/tests/Drupal/Tests/TestRequirementsTrait.php \Drupal\Tests\TestRequirementsTrait
- 8.9.x core/tests/Drupal/Tests/TestRequirementsTrait.php \Drupal\Tests\TestRequirementsTrait
Allows test classes to require Drupal modules as dependencies.
This trait is assumed to be on a subclass of \PHPUnit\Framework\TestCase, and overrides \PHPUnit\Framework\TestCase::checkRequirements(). This allows the test to be marked as skipped before any kernel boot processes have happened.
Hierarchy
- trait \Drupal\Tests\TestRequirementsTrait
Deprecated
in drupal:12.0.0 and is removed from drupal:13.0.0. Use \Drupal\Tests\DrupalTestCaseTrait.
See also
https://www.drupal.org/node/3574112
File
-
core/
tests/ Drupal/ Tests/ TestRequirementsTrait.php, line 21
Namespace
Drupal\TestsView source
trait TestRequirementsTrait {
/**
* Returns the Drupal root directory.
*
* @return string
* The Drupal root directory.
*
* @deprecated in drupal:12.0.0 and is removed from drupal:13.0.0. Access
* $this->root directly.
*
* @see https://www.drupal.org/node/3574112
*/
protected static function getDrupalRoot() : string {
@trigger_error(__METHOD__ . '() is deprecated in drupal:12.0.0 and is removed from drupal:13.0.0. Access $this->root directly. See https://www.drupal.org/node/3574112', E_USER_DEPRECATED);
return dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)), 2);
}
}
Members
| Title Sort descending | Deprecated | Modifiers | Object type | Summary |
|---|---|---|---|---|
| TestRequirementsTrait::getDrupalRoot | Deprecated | protected static | function | Returns the Drupal root directory. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.