You are here

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

1 call to ContainerMockTrait::mockTranslator()
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 26

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 mockTranslator() {
  $this
    ->mockContainer();

  // Mock the string_translation service; calling its translate()
  // method will return the original, unprocessed string.
  $translator = $this
    ->createMock('\\Drupal\\Core\\StringTranslation\\TranslationInterface');
  $translator
    ->method('translate')
    ->willReturnArgument(0);
  $this->container
    ->set('string_translation', $translator);
}