You are here

public function QueryStringTest::testWithOnlyOneResult in Facets 8

Tests with only one result.

File

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

Class

QueryStringTest
Unit test for processor.

Namespace

Drupal\Tests\facets\Unit\Plugin\url_processor

Code

public function testWithOnlyOneResult() {
  $facet = new Facet([], 'facets_facet');
  $facet
    ->setFieldIdentifier('test');
  $facet
    ->setUrlAlias('test');
  $facet
    ->setFacetSourceId('facet_source__dummy');
  $facet
    ->setShowOnlyOneResult(TRUE);
  $this->originalResults[1]
    ->setActiveState(TRUE);
  $this->originalResults[2]
    ->setActiveState(TRUE);
  $this->processor = new QueryString([
    'facet' => $facet,
  ], 'query_string', [], new Request(), $this->entityManager, $this->eventDispatcher);
  $results = $this->processor
    ->buildUrls($facet, $this->originalResults);
  $this
    ->assertEquals('route:test?f%5B0%5D=test%3A' . $results[0]
    ->getRawValue(), $results[0]
    ->getUrl()
    ->toUriString());
  $this
    ->assertEquals('route:test?f%5B0%5D=test%3A' . $results[3]
    ->getRawValue(), $results[3]
    ->getUrl()
    ->toUriString());
  $this
    ->assertEquals('route:test?f%5B0%5D=test%3A' . $results[4]
    ->getRawValue(), $results[4]
    ->getUrl()
    ->toUriString());
  $this
    ->assertEquals('route:test', $results[1]
    ->getUrl()
    ->toUriString());
  $this
    ->assertEquals('route:test', $results[2]
    ->getUrl()
    ->toUriString());
}