You are here

public function PrettyPathsFunctionalTest::testPrettyPathsUrlProcessor in Facets Pretty Paths 8

Tests the Facets Pretty Paths URL preprocessor..

File

tests/src/Functional/PrettyPathsFunctionalTest.php, line 45

Class

PrettyPathsFunctionalTest
Main functional test for the Pretty Paths URL processor.

Namespace

Drupal\Tests\facets_pretty_paths\Functional

Code

public function testPrettyPathsUrlProcessor() {
  $this
    ->ensureSearchResults();

  /** @var \Drupal\facets\FacetInterface $facet */
  $facet = $this->container
    ->get('entity_type.manager')
    ->getStorage('facets_facet')
    ->load('content_type');
  $urls = $this
    ->buildUrlsFromFacet($facet);

  // We expect 2 URLs to have been generated.
  $this
    ->assertCount(2, $urls);
  foreach ($urls as $url) {
    $this
      ->assertEquals('view.search.page_1', $url
      ->getRouteName());
  }
  $this
    ->assertEquals('content_type/article', $urls[0]
    ->getRouteParameters()['facets_query']);
  $this
    ->assertEquals('content_type/page', $urls[1]
    ->getRouteParameters()['facets_query']);
}