You are here

protected function TranslateEntityProcessorTest::setUp in Facets 8

Overrides UnitTestCase::setUp

File

tests/src/Unit/Plugin/processor/TranslateEntityProcessorTest.php, line 45

Class

TranslateEntityProcessorTest
Unit test for processor.

Namespace

Drupal\Tests\facets\Unit\Plugin\processor

Code

protected function setUp() {
  parent::setUp();

  // Mock language manager.
  $this->languageManager = $this
    ->getMockBuilder(LanguageManagerInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $language = new Language([
    'langcode' => 'en',
  ]);
  $this->languageManager
    ->expects($this
    ->any())
    ->method('getCurrentLanguage')
    ->will($this
    ->returnValue($language));

  // Mock entity type manager.
  $this->entityTypeManager = $this
    ->getMockBuilder(EntityTypeManagerInterface::class)
    ->disableOriginalConstructor()
    ->getMock();

  // Create and set a global container with the language manager and entity
  // type manager.
  $container = new ContainerBuilder();
  $container
    ->set('language_manager', $this->languageManager);
  $container
    ->set('entity_type.manager', $this->entityTypeManager);
  \Drupal::setContainer($container);
}