You are here

public function SliderProcessorTest::testPostQueryStep in Facets 8

Tests the post query method with step > 1.

@covers ::postQuery

File

modules/facets_range_widget/tests/src/Unit/Plugin/processor/SliderProcessorTest.php, line 179

Class

SliderProcessorTest
Unit test for processor.

Namespace

Drupal\Tests\facets_range_widget\Unit\Plugin\processor

Code

public function testPostQueryStep() {
  $widgetconfig = [
    'min_type' => 'foo',
    'step' => 2,
  ];
  $facet = new Facet([], 'facets_facet');
  $facet
    ->setWidget('raw', $widgetconfig);
  $this
    ->configureContainer($widgetconfig);
  $result_lower = new Result($facet, 5, '5', 4);
  $result_higher = new Result($facet, 15, '15', 4);
  $facet
    ->setResults([
    $result_lower,
    $result_higher,
  ]);

  // Process the data.
  $this->processor
    ->postQuery($facet);
  $new_results = $facet
    ->getResults();
  $this
    ->assertCount(6, $new_results);
  $this
    ->assertEquals(5, $new_results[0]
    ->getRawValue());
  $this
    ->assertEquals(4, $new_results[0]
    ->getCount());
  $this
    ->assertEquals(7, $new_results[1]
    ->getRawValue());
  $this
    ->assertEquals(0, $new_results[1]
    ->getCount());
  $this
    ->assertEquals(15, $new_results[5]
    ->getRawValue());
  $this
    ->assertEquals(4, $new_results[5]
    ->getCount());
}