function DatabaseTest::setUp
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Database/DatabaseTest.php \Drupal\Tests\Core\Database\DatabaseTest::setUp()
- 8.9.x core/tests/Drupal/Tests/Core/Database/DatabaseTest.php \Drupal\Tests\Core\Database\DatabaseTest::setUp()
Overrides UnitTestCase::setUp
File
-
core/
tests/ Drupal/ Tests/ Core/ Database/ DatabaseTest.php, line 42
Class
- DatabaseTest
- @coversDefaultClass \Drupal\Core\Database\Database
Namespace
Drupal\Tests\Core\DatabaseCode
protected function setUp() : void {
parent::setUp();
$this->additionalClassloader = new ClassLoader();
$this->additionalClassloader
->register();
// Mock the container so we don't need to mock drupal_valid_test_ua().
// @see \Drupal\Core\Extension\ExtensionDiscovery::scan()
$this->root = dirname(__DIR__, 6);
$databaseDriverList = new DatabaseDriverList($this->root, 'database_driver', new NullBackend('database_driver'));
$container = $this->createMock(ContainerInterface::class);
$container->expects($this->any())
->method('has')
->willReturnMap([
[
'kernel',
TRUE,
],
[
'extension.list.database_driver',
TRUE,
],
]);
$container->expects($this->any())
->method('get')
->with('extension.list.database_driver')
->willReturn($databaseDriverList);
$container->expects($this->any())
->method('getParameter')
->with('site.path')
->willReturn('');
\Drupal::setContainer($container);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.