public function CountLimitProcessorTest::testMaxValue in Facets 8
Tests maximum values.
File
- tests/
src/ Unit/ Plugin/ processor/ CountLimitProcessorTest.php, line 144
Class
- CountLimitProcessorTest
- Unit test for processor.
Namespace
Drupal\Tests\facets\Unit\Plugin\processorCode
public function testMaxValue() {
$facet = new Facet([], 'facets_facet');
$facet
->setResults($this->originalResults);
$facet
->addProcessor([
'processor_id' => 'count_limit',
'weights' => [],
'settings' => [],
]);
$this->processor
->setConfiguration([
'maximum_items' => 14,
]);
$sorted_results = $this->processor
->build($facet, $this->originalResults);
$this
->assertCount(2, $sorted_results);
$this
->assertEquals('llama', $sorted_results[0]
->getDisplayValue());
$this
->assertEquals('badger', $sorted_results[1]
->getDisplayValue());
$this->processor
->setConfiguration([
'maximum_items' => 140,
]);
$sorted_results = $this->processor
->build($facet, $this->originalResults);
$this
->assertCount(3, $sorted_results);
$this
->assertEquals('llama', $sorted_results[0]
->getDisplayValue());
$this
->assertEquals('badger', $sorted_results[1]
->getDisplayValue());
$this
->assertEquals('duck', $sorted_results[2]
->getDisplayValue());
$this->processor
->setConfiguration([
'maximum_items' => 1,
]);
$sorted_results = $this->processor
->build($facet, $this->originalResults);
$this
->assertCount(0, $sorted_results);
}