function TestDiscoveryTest::getTestDiscoveryMock

Same name in other branches
  1. 8.9.x core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php \Drupal\Tests\simpletest\Unit\TestDiscoveryTest::getTestDiscoveryMock()
  2. 8.9.x core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::getTestDiscoveryMock()
  3. 10 core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::getTestDiscoveryMock()
  4. 11.x core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::getTestDiscoveryMock()

Mock a TestDiscovery object to return specific extension values.

2 calls to TestDiscoveryTest::getTestDiscoveryMock()
TestDiscoveryTest::testGetTestClasses in core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php
@covers ::getTestClasses
TestDiscoveryTest::testGetTestClassesWithSelectedTypes in core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php
@covers ::getTestClasses

File

core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php, line 419

Class

TestDiscoveryTest
@coversDefaultClass \Drupal\Core\Test\TestDiscovery @group Test

Namespace

Drupal\Tests\Core\Test

Code

protected function getTestDiscoveryMock($app_root, $extensions) {
    $class_loader = $this->prophesize(ClassLoader::class);
    $module_handler = $this->prophesize(ModuleHandlerInterface::class);
    $test_discovery = $this->getMockBuilder(TestDiscovery::class)
        ->setConstructorArgs([
        $app_root,
        $class_loader->reveal(),
        $module_handler->reveal(),
    ])
        ->onlyMethods([
        'getExtensions',
    ])
        ->getMock();
    $test_discovery->expects($this->any())
        ->method('getExtensions')
        ->willReturn($extensions);
    return $test_discovery;
}

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