You are here

public function TaxonomyTestTrait::setupContainer in Search API 8

Sets up the container with necessary services.

2 calls to TaxonomyTestTrait::setupContainer()
AllTermsArgumentTest::setUp in tests/src/Unit/Views/AllTermsArgumentTest.php
TaxonomyTermArgumentTest::setUp in tests/src/Unit/Views/TaxonomyTermArgumentTest.php

File

tests/src/Unit/Views/TaxonomyTestTrait.php, line 42

Class

TaxonomyTestTrait
Provides common methods for unit tests using taxonomy terms.

Namespace

Drupal\Tests\search_api\Unit\Views

Code

public function setupContainer() {
  $this->container = new ContainerBuilder();
  $this->entityRepository = $this
    ->createMock(EntityRepositoryInterface::class);
  $this->termStorage = $this
    ->createMock(TermStorageInterface::class);
  $entity_type_manager = $this
    ->createMock(EntityTypeManagerInterface::class);
  $entity_type_manager
    ->expects($this
    ->any())
    ->method('getStorage')
    ->willReturnMap([
    [
      'taxonomy_term',
      $this->termStorage,
    ],
  ]);
  $this->container
    ->set('entity.repository', $this->entityRepository);
  $this->container
    ->set('entity_type.manager', $entity_type_manager);
  $this->container
    ->set('string_translation', $this
    ->createMock(TranslationInterface::class));
  \Drupal::setContainer($this->container);
}