You are here

protected function DatabaseTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 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() : 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);
}