You are here

private function UnitTestBase::prepareContainer in Entity Construction Kit (ECK) 8

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 49

Class

UnitTestBase
Base class for unit tests.

Namespace

Drupal\Tests\eck\Unit

Code

private function prepareContainer() {
  $container_class = 'Drupal\\Core\\DependencyInjection\\Container';
  $methods = get_class_methods($container_class);
  $container = $this
    ->getMockBuilder($container_class)
    ->disableOriginalConstructor()
    ->setMethods($methods)
    ->getMock();
  \Drupal::setContainer($container);
  $container
    ->method('get')
    ->willReturnCallback([
    $this,
    'containerMockGetServiceCallback',
  ]);
}