You are here

public function SliderProcessorTest::testPostQuery in Facets 8

Tests the post query method.

@covers ::postQuery

File

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

Class

SliderProcessorTest
Unit test for processor.

Namespace

Drupal\Tests\facets_range_widget\Unit\Plugin\processor

Code

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

  // Process the data.
  $startTime = microtime(TRUE);
  $this->processor
    ->postQuery($facet);
  $new_results = $facet
    ->getResults();
  $stopTime = microtime(TRUE);
  if ($stopTime - $startTime > 1) {
    $this
      ->fail('Test is too slow');
  }
  $this
    ->assertCount(146, $new_results);
  $this
    ->assertEquals(5, $new_results[0]
    ->getRawValue());
  $this
    ->assertEquals(1, $new_results[0]
    ->getCount());
  $this
    ->assertEquals(6, $new_results[1]
    ->getRawValue());
  $this
    ->assertEquals(0, $new_results[1]
    ->getCount());
}