class StubTestSuiteBase

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Test/TestSuiteBaseTest.php \Drupal\Tests\Core\Test\StubTestSuiteBase
  2. 8.9.x core/tests/Drupal/Tests/Core/Test/TestSuiteBaseTest.php \Drupal\Tests\Core\Test\StubTestSuiteBase

Stub subclass of TestSuiteBase.

We use this class to alter the behavior of TestSuiteBase so it can be testable.

@phpstan-ignore-next-line

Hierarchy

  • class \Drupal\Tests\TestSuites\TestSuiteBase extends \PHPUnit\Framework\TestSuite
    • class \Drupal\Tests\Core\Test\StubTestSuiteBase extends \Drupal\Tests\TestSuites\TestSuiteBase

Expanded class hierarchy of StubTestSuiteBase

File

core/tests/Drupal/Tests/Core/Test/TestSuiteBaseTest.php, line 132

Namespace

Drupal\Tests\Core\Test
View source
class StubTestSuiteBase extends TestSuiteBase {
    
    /**
     * Test files discovered by addTestsBySuiteNamespace().
     *
     * @var string[]
     */
    public $testFiles = [];
    public function __construct(string $name) {
        @trigger_error(__CLASS__ . ' is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no replacement and test discovery will be handled differently in PHPUnit 10. See https://www.drupal.org/node/3405829', E_USER_DEPRECATED);
        // @phpstan-ignore-next-line
        parent::__construct($name);
    }
    
    /**
     * {@inheritdoc}
     */
    protected function findExtensionDirectories($root) {
        // We have to stub findExtensionDirectories() because we can't inject a
        // vfsStream filesystem into drupal_phpunit_find_extension_directories(),
        // which uses \SplFileInfo->getRealPath(). getRealPath() resolves
        // stream-based paths to an empty string. See
        // https://github.com/mikey179/vfsStream/wiki/Known-Issues
        return [];
    }
    
    /**
     * {@inheritdoc}
     */
    public function addTestFiles($filenames) : void {
        // We stub addTestFiles() because the parent implementation can't deal with
        // vfsStream-based filesystems due to an error in
        // stream_resolve_include_path(). See
        // https://github.com/mikey179/vfsStream/issues/5 Here we just store the
        // test file being added in $this->testFiles.
        $this->testFiles = array_merge($this->testFiles, $filenames);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
StubTestSuiteBase::$testFiles public property Test files discovered by addTestsBySuiteNamespace().
StubTestSuiteBase::addTestFiles public function
StubTestSuiteBase::findExtensionDirectories protected function Finds extensions in a Drupal installation. Overrides TestSuiteBase::findExtensionDirectories
StubTestSuiteBase::__construct public function
TestSuiteBase::addTestsBySuiteNamespace protected function Find and add tests to the suite for core and any extensions.

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