You are here

public function UidToUserNameCallbackProcessorTest::testDeletedEntityResults in Facets 8

Tests that deleted entity results were correctly handled.

File

tests/src/Unit/Plugin/processor/UidToUserNameCallbackProcessorTest.php, line 91

Class

UidToUserNameCallbackProcessorTest
Unit test for processor.

Namespace

Drupal\Tests\facets\Unit\Plugin\processor

Code

public function testDeletedEntityResults() {
  $user_storage = $this
    ->createMock(EntityStorageInterface::class);
  $entity_type_manager = $this
    ->createMock(EntityTypeManagerInterface::class);
  $entity_repository = $this
    ->createMock(EntityTypeRepositoryInterface::class);
  $entity_repository
    ->expects($this
    ->any())
    ->method('getEntityTypeFromClass')
    ->willReturn('user');
  $entity_type_manager
    ->expects($this
    ->any())
    ->method('getStorage')
    ->willReturn($user_storage);
  $user_storage
    ->method('load')
    ->willReturn(NULL);
  $container = new ContainerBuilder();
  $container
    ->set('entity_type.repository', $entity_repository);
  $container
    ->set('entity_type.manager', $entity_type_manager);
  \Drupal::setContainer($container);
  $facet = new Facet([], 'facets_facet');
  $original_results = [
    new Result($facet, 1, 1, 5),
  ];
  $facet
    ->setResults($original_results);
  $filtered_results = $this->processor
    ->build($facet, $original_results);
  $this
    ->assertEmpty($filtered_results);
}