You are here

protected function ContainerMockTrait::mockLogger in Drupal 7 to 8/9 Module Upgrader 8

1 call to ContainerMockTrait::mockLogger()
TestBase::setUp in tests/src/Unit/TestBase.php
Mocks an entire module, called foo, in a virtual file system.

File

tests/src/Unit/ContainerMockTrait.php, line 36

Class

ContainerMockTrait
A trait for tests that need a mock container; contains (deprecated) methods to mock basic translation and logging services as well.

Namespace

Drupal\Tests\drupalmoduleupgrader\Unit

Code

protected function mockLogger() {
  $this
    ->mockContainer();

  // Mock the logger.factory service and a logger channel.
  $factory = $this
    ->createMock('\\Drupal\\Core\\Logger\\LoggerChannelFactoryInterface');
  $channel = $this
    ->createMock('\\Drupal\\Core\\Logger\\LoggerChannelInterface');
  $factory
    ->method('get')
    ->willReturn($channel);
  $this->container
    ->set('logger.factory', $factory);
}