function TestRequirementsTrait::checkRequirements
Same name in other branches
- 9 core/tests/Drupal/Tests/TestRequirementsTrait.php \Drupal\Tests\TestRequirementsTrait::checkRequirements()
- 8.9.x core/tests/Drupal/Tests/TestRequirementsTrait.php \Drupal\Tests\TestRequirementsTrait::checkRequirements()
Check module requirements for the Drupal use case.
This method is assumed to override \PHPUnit\Framework\TestCase::checkRequirements().
Throws
\PHPUnit\Framework\SkippedTestError Thrown when the requirements are not met, and this test should be skipped. Callers should not catch this exception.
Deprecated
in drupal:10.3.0 and is removed from drupal:11.0.0. There is no replacement.
See also
https://www.drupal.org/node/3418480
4 calls to TestRequirementsTrait::checkRequirements()
- BrowserMissingDependentModuleMethodTest::publicCheckRequirements in core/
tests/ fixtures/ BrowserMissingDependentModuleMethodTest.php - Public access for checkRequirements() to avoid reflection.
- BrowserMissingDependentModuleTest::publicCheckRequirements in core/
tests/ fixtures/ BrowserMissingDependentModuleTest.php - Public access for checkRequirements() to avoid reflection.
- KernelMissingDependentModuleMethodTest::publicCheckRequirements in core/
tests/ fixtures/ KernelMissingDependentModuleMethodTest.php - Public access for checkRequirements() to avoid reflection.
- KernelMissingDependentModuleTest::publicCheckRequirements in core/
tests/ fixtures/ KernelMissingDependentModuleTest.php - Public access for checkRequirements() to avoid reflection.
File
-
core/
tests/ Drupal/ Tests/ TestRequirementsTrait.php, line 44
Class
- TestRequirementsTrait
- Allows test classes to require Drupal modules as dependencies.
Namespace
Drupal\TestsCode
protected function checkRequirements() {
@trigger_error(__METHOD__ . '() is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3418480', E_USER_DEPRECATED);
if (!$this->getName(FALSE) || !method_exists($this, $this->getName(FALSE))) {
return;
}
$missingRequirements = Test::getMissingRequirements(static::class, $this->getName(FALSE));
if (!empty($missingRequirements)) {
$this->markTestSkipped(implode(PHP_EOL, $missingRequirements));
}
$root = static::getDrupalRoot();
// Check if required dependencies exist.
$annotations = Test::parseTestMethodAnnotations(static::class, $this->getName());
if (!empty($annotations['class']['requires'])) {
$this->checkModuleRequirements($root, $annotations['class']['requires']);
}
if (!empty($annotations['method']['requires'])) {
$this->checkModuleRequirements($root, $annotations['method']['requires']);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.