You are here

public function CountLimitProcessorTest::testBetweenMinAndMaxValue in Facets 8

Tests between minimum and maximum values.

File

tests/src/Unit/Plugin/processor/CountLimitProcessorTest.php, line 118

Class

CountLimitProcessorTest
Unit test for processor.

Namespace

Drupal\Tests\facets\Unit\Plugin\processor

Code

public function testBetweenMinAndMaxValue() {
  $facet = new Facet([], 'facets_facet');
  $facet
    ->setResults($this->originalResults);
  $facet
    ->addProcessor([
    'processor_id' => 'count_limit',
    'weights' => [],
    'settings' => [],
  ]);
  $this->processor
    ->setConfiguration([
    'minimum_items' => 6,
    'maximum_items' => 14,
  ]);
  $sorted_results = $this->processor
    ->build($facet, $this->originalResults);
  $this
    ->assertCount(1, $sorted_results);
  $this
    ->assertEquals('llama', $sorted_results[0]
    ->getDisplayValue());
  $this->processor
    ->setConfiguration([
    'minimum_items' => 60,
    'maximum_items' => 140,
  ]);
  $sorted_results = $this->processor
    ->build($facet, $this->originalResults);
  $this
    ->assertCount(0, $sorted_results);
  $this->processor
    ->setConfiguration([
    'minimum_items' => 1,
    'maximum_items' => 10,
  ]);
  $sorted_results = $this->processor
    ->build($facet, $this->originalResults);
  $this
    ->assertCount(2, $sorted_results);
}