You are here

protected function TestSuiteBase::addExtensionTestsBySuiteNamespace in Drupal driver for SQL Server and SQL Azure 3.0.x

Same name in this branch
  1. 3.0.x dev/appveyor/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespace()
  2. 3.0.x dev/travis/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespace()
Same name and namespace in other branches
  1. 4.2.x dev/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespace()
  2. 3.1.x dev/appveyor/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespace()
  3. 3.1.x dev/travis/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespace()
  4. 4.0.x dev/appveyor/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespace()
  5. 4.0.x dev/travis/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespace()
  6. 4.1.x dev/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespace()

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

Parameters

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

string $suite_namespace: SubNamespace used to separate test suite. Examples: Unit, Functional.

string $pattern: REGEXP pattern to apply to file name.

File

dev/travis/TestSuites/TestSuiteBase.php, line 102

Class

TestSuiteBase
Base class for Drupal test suites.

Namespace

Drupal\Tests\sqlsrv\TestSuites

Code

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

  // Extensions' tests will always be in the namespace
  // Drupal\Tests\$extension_name\$suite_namespace\ and be in the
  // $extension_path/tests/src/$suite_namespace directory. Not all extensions
  // will have all kinds of tests.
  foreach ($this
    ->findExtensionDirectories($root) as $extension_name => $dir) {
    if (preg_match("#^{$pattern}(.*)\$#i", $extension_name) !== 0) {
      $test_path = "{$dir}/tests/src/{$suite_namespace}";
      if (is_dir($test_path)) {
        $passing_tests = [];
        $tests = TestDiscovery::scanDirectory("Drupal\\Tests\\{$extension_name}\\{$suite_namespace}\\", $test_path);
        foreach ($tests as $test) {
          if (!in_array($test, $failing_classes)) {
            $passing_tests[] = $test;
          }
        }
        $this
          ->addTestFiles($passing_tests);
      }
    }
  }
}