You are here

protected function TestSuiteBase::addExtensionTestsBySuiteNamespaceAndChunk 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::addExtensionTestsBySuiteNamespaceAndChunk()
  2. 3.0.x dev/travis/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespaceAndChunk()
Same name and namespace in other branches
  1. 4.2.x dev/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespaceAndChunk()
  2. 3.1.x dev/appveyor/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespaceAndChunk()
  3. 3.1.x dev/travis/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespaceAndChunk()
  4. 4.0.x dev/appveyor/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespaceAndChunk()
  5. 4.0.x dev/travis/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespaceAndChunk()
  6. 4.1.x dev/TestSuites/TestSuiteBase.php \Drupal\Tests\sqlsrv\TestSuites\TestSuiteBase::addExtensionTestsBySuiteNamespaceAndChunk()

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.

int $index: The chunk number to test.

File

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

Class

TestSuiteBase
Base class for Drupal test suites.

Namespace

Drupal\Tests\sqlsrv\TestSuites

Code

protected function addExtensionTestsBySuiteNamespaceAndChunk($root, $suite_namespace, $index = 0) {
  $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.
  $passing_tests = [];
  foreach ($this
    ->findExtensionDirectories($root) as $extension_name => $dir) {
    $test_path = "{$dir}/tests/src/{$suite_namespace}";
    if (is_dir($test_path)) {
      $tests = TestDiscovery::scanDirectory("Drupal\\Tests\\{$extension_name}\\{$suite_namespace}\\", $test_path);
      foreach ($tests as $test) {
        if (!in_array($test, $failing_classes)) {
          $passing_tests[] = $test;
        }
      }
    }
  }
  $sizes = [
    17,
    34,
    25,
    30,
    30,
    25,
    25,
    25,
    30,
    25,
    25,
    15,
    25,
    25,
    25,
    25,
    25,
    25,
    30,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    20,
    20,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    30,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
    25,
  ];
  $index = rand(0, 58);
  $length = $sizes[$index];
  $offset = $index == 0 ? 0 : array_sum(array_splice($sizes, 0, $index));
  $subset = array_splice($passing_tests, $offset, $length);
  fwrite(STDOUT, "SPLICE:" . $index);
  $this
    ->addTestFiles($subset);
}