You are here

public function QueryStringTest::testBuild in Facets 8

Tests with default build.

File

tests/src/Unit/Plugin/url_processor/QueryStringTest.php, line 181

Class

QueryStringTest
Unit test for processor.

Namespace

Drupal\Tests\facets\Unit\Plugin\url_processor

Code

public function testBuild() {
  $facet = new Facet([], 'facets_facet');
  $facet
    ->setFieldIdentifier('test');
  $facet
    ->setUrlAlias('test');
  $facet
    ->setFacetSourceId('facet_source__dummy');
  $request = new Request();
  $request->query
    ->set('f', []);
  $this->processor = new QueryString([
    'facet' => $facet,
  ], 'query_string', [], $request, $this->entityManager, $this->eventDispatcher);
  $results = $this->processor
    ->buildUrls($facet, $this->originalResults);
  $this
    ->assertEquals('f', $this->processor
    ->getFilterKey());

  /** @var \Drupal\facets\Result\ResultInterface $r */
  foreach ($results as $r) {
    $this
      ->assertInstanceOf(ResultInterface::class, $r);
    $this
      ->assertEquals('route:test?f%5B0%5D=test%3A' . $r
      ->getRawValue(), $r
      ->getUrl()
      ->toUriString());
  }
}