You are here

private function UnitTestBase::prepareContainer in Select (or other) 4.x

Same name and namespace in other branches
  1. 8 tests/src/Unit/UnitTestBase.php \Drupal\Tests\select_or_other\Unit\UnitTestBase::prepareContainer()

Prepares a mocked service container.

1 call to UnitTestBase::prepareContainer()
UnitTestBase::setUp in tests/src/Unit/UnitTestBase.php

File

tests/src/Unit/UnitTestBase.php, line 41

Class

UnitTestBase

Namespace

Drupal\Tests\select_or_other\Unit

Code

private function prepareContainer() {
  $container_class = 'Drupal\\Core\\DependencyInjection\\Container';
  $methods = get_class_methods($container_class);

  /** @var ContainerInterface $container */
  $this->containerMock = $container = $this
    ->getMockBuilder($container_class)
    ->disableOriginalConstructor()
    ->setMethods($methods)
    ->getMock();
  \Drupal::setContainer($container);
  $this->containerMock
    ->method('get')
    ->willReturnCallback([
    $this,
    'containerMockGetServiceCallback',
  ]);
}