You are here

public function SummaryEntityTest::testProcessor in Facets 8

Tests processor behavior.

@covers ::getProcessorsByStage @covers ::getProcessors @covers ::getProcessorConfigs @covers ::addProcessor @covers ::removeProcessor @covers ::loadProcessors

File

modules/facets_summary/tests/src/Kernel/SummaryEntityTest.php, line 91

Class

SummaryEntityTest
Class SummaryEntityTest.

Namespace

Drupal\Tests\facets_summary\Kernel

Code

public function testProcessor() {
  $entity = new FacetsSummary([], 'facets_summary');
  $this
    ->assertEmpty($entity
    ->getProcessorConfigs());
  $this
    ->assertEmpty($entity
    ->getProcessors());
  $this
    ->assertEmpty($entity
    ->getProcessorsByStage(ProcessorInterface::STAGE_BUILD));
  $id = 'hide_when_not_rendered';
  $config = [
    'processor_id' => $id,
    'weights' => [],
    'settings' => [],
  ];
  $entity
    ->addProcessor($config);
  $this
    ->assertEquals([
    $id => $config,
  ], $entity
    ->getProcessorConfigs());
  $this
    ->assertNotEmpty($entity
    ->getProcessorsByStage(ProcessorInterface::STAGE_BUILD));
  $processors = $entity
    ->getProcessors();
  $this
    ->assertArrayHasKey($id, $processors);
  $this
    ->assertInstanceOf(HideWhenNotRenderedProcessor::class, $processors[$id]);
  $entity
    ->removeProcessor($id);
  $this
    ->assertEmpty($entity
    ->getProcessorsByStage(ProcessorInterface::STAGE_BUILD));
}