You are here

protected function TestSuiteBase::addCoreKernelTestsByName in Drupal driver for SQL Server and SQL Azure 4.1.x

Same name and namespace in other branches
  1. 4.2.x dev/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addCoreKernelTestsByName()

Find and add tests to the suite for core and any extensions.

Parameters

string $root: Path to the root of the Drupal installation.

string $pattern: Regex pattern to match to the test class name.

File

dev/TestSuites/TestSuiteBase.php, line 61

Class

TestSuiteBase
Base class for Drupal test suites.

Namespace

Drupal\Tests\sqlsrv\TestSuites

Code

protected function addCoreKernelTestsByName($root, $pattern) {
  $failing_classes = [];
  foreach ($this->failingClasses as $failing_class) {
    $failing_classes[] = $root . $failing_class;
  }

  // Core's Kernel tests are in the namespace Drupal\KernelTests\ and are
  // always inside of core/tests/Drupal/KernelTests.
  $passing_tests = [];
  $tests = TestDiscovery::scanDirectory("Drupal\\KernelTests\\", "{$root}/core/tests/Drupal/KernelTests");
  foreach ($tests as $test) {
    if (!in_array($test, $failing_classes) && preg_match("#.*\\/{$pattern}[a-zA-z]*\\.php\$#i", $test) !== 0) {
      $passing_tests[] = $test;
    }
  }
  $this
    ->addTestFiles($passing_tests);
}