function DatabaseTest::setUp

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Database/DatabaseTest.php \Drupal\Tests\Core\Database\DatabaseTest::setUp()
  2. 10 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 37

Class

DatabaseTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Database%21Database.php/class/Database/9" title="Primary front-controller for the database system." class="local">\Drupal\Core\Database\Database</a>

Namespace

Drupal\Tests\Core\Database

Code

protected function setUp() : void {
    $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);
    $container = $this->createMock(ContainerInterface::class);
    $container->expects($this->any())
        ->method('has')
        ->with('kernel')
        ->willReturn(TRUE);
    $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.