function DrupalStandardsListenerTrait::fail

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Listeners/DrupalStandardsListenerTrait.php \Drupal\Tests\Listeners\DrupalStandardsListenerTrait::fail()

Signals a coding standards failure to the user.

Parameters

\PHPUnit\Framework\TestCase $test: The test where we should insert our test failure.

string $message: The message to add to the failure notice. The test class name and test name will be appended to this message automatically.

1 call to DrupalStandardsListenerTrait::fail()
DrupalStandardsListenerTrait::checkValidCoversForTest in core/tests/Drupal/Tests/Listeners/DrupalStandardsListenerTrait.php
Check an individual test run for valid @covers annotation.

File

core/tests/Drupal/Tests/Listeners/DrupalStandardsListenerTrait.php, line 29

Class

DrupalStandardsListenerTrait
Listens for PHPUnit tests and fails those with invalid coverage annotations.

Namespace

Drupal\Tests\Listeners

Code

private function fail(TestCase $test, $message) {
    // Add the report to the test's results.
    $message .= ': ' . get_class($test) . '::' . $test->getName();
    $fail = new AssertionFailedError($message);
    $result = $test->getTestResultObject();
    $result->addFailure($test, $fail, 0);
}

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