public function FacetTest::testProcessor in Facets 8
Tests widget processor behavior.
@covers ::getProcessorsByStage @covers ::getProcessors @covers ::getProcessorConfigs @covers ::addProcessor @covers ::removeProcessor @covers ::loadProcessors
File
- tests/
src/ Kernel/ Entity/ FacetTest.php, line 119
Class
- FacetTest
- Class FacetTest.
Namespace
Drupal\Tests\facets\Kernel\EntityCode
public function testProcessor() {
$entity = new Facet([], 'facets_facet');
$this
->assertEmpty($entity
->getProcessorConfigs());
$this
->assertEmpty($entity
->getProcessors());
$this
->assertEmpty($entity
->getProcessorsByStage(ProcessorInterface::STAGE_PRE_QUERY));
$this
->assertEmpty($entity
->getProcessorsByStage(ProcessorInterface::STAGE_POST_QUERY));
$this
->assertEmpty($entity
->getProcessorsByStage(ProcessorInterface::STAGE_BUILD));
$this
->assertEmpty($entity
->getProcessorsByStage(ProcessorInterface::STAGE_SORT));
$id = 'hide_non_narrowing_result_processor';
$config = [
'processor_id' => $id,
'weights' => [],
'settings' => [],
];
$entity
->addProcessor($config);
$this
->assertEquals([
$id => $config,
], $entity
->getProcessorConfigs());
$this
->assertNotEmpty($entity
->getProcessorsByStage(ProcessorInterface::STAGE_BUILD));
$this
->assertEmpty($entity
->getProcessorsByStage(ProcessorInterface::STAGE_SORT));
$processors = $entity
->getProcessors();
$this
->assertArrayHasKey('hide_non_narrowing_result_processor', $processors);
$this
->assertInstanceOf(HideNonNarrowingResultProcessor::class, $processors['hide_non_narrowing_result_processor']);
$entity
->removeProcessor($id);
$this
->assertEmpty($entity
->getProcessorsByStage(ProcessorInterface::STAGE_BUILD));
$this
->assertEmpty($entity
->getProcessorsByStage(ProcessorInterface::STAGE_SORT));
}