function DrupalTestCaseTrait::skipTestWithAttribute

Supports skipping tests with the Skip attribute.

This is run with a high priority to prevent any setUp() functions from executing, avoiding any Drupal bootstrap.

@internal

Attributes

#[Before(200)]

File

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

Class

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

Namespace

Drupal\Tests

Code

final protected function skipTestWithAttribute() : void {
  $reflection = new \ReflectionMethod(static::class, $this->name());
  $attribute = $reflection->getAttributes(Skip::class, \ReflectionAttribute::IS_INSTANCEOF)[0] ?? NULL;
  if ($attribute) {
    Assert::markTestSkipped($attribute->newInstance()->message);
  }
}

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