function DatabaseTest::setUp

Same name in other branches
  1. 9 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 38

Class

DatabaseTest
@coversDefaultClass \Drupal\Core\Database\Database

Namespace

Drupal\Tests\Core\Database

Code

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