function TestRequirementsTrait::checkRequirements

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/TestRequirementsTrait.php \Drupal\Tests\TestRequirementsTrait::checkRequirements()
  2. 10 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.

5 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.
ToolkitGdTest::checkRequirements in core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
Check module requirements for the Drupal use case.
1 method overrides TestRequirementsTrait::checkRequirements()
ToolkitGdTest::checkRequirements in core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
Check module requirements for the Drupal use case.

File

core/tests/Drupal/Tests/TestRequirementsTrait.php, line 37

Class

TestRequirementsTrait
Allows test classes to require Drupal modules as dependencies.

Namespace

Drupal\Tests

Code

protected function checkRequirements() {
    if (!$this->getName(FALSE) || !method_exists($this, $this->getName(FALSE))) {
        return;
    }
    $missingRequirements = Test::getMissingRequirements(get_class($this), $this->getName(FALSE));
    if (!empty($missingRequirements)) {
        $this->markTestSkipped(implode(PHP_EOL, $missingRequirements));
    }
    $root = static::getDrupalRoot();
    // Check if required dependencies exist.
    $annotations = $this->getAnnotations();
    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.