You are here

public function PrettyPathsFunctionalTest::testPrettyPathsCoder in Facets Pretty Paths 8

Tests that the coder plugins get called properly when generating the URLs.

File

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

Class

PrettyPathsFunctionalTest
Main functional test for the Pretty Paths URL processor.

Namespace

Drupal\Tests\facets_pretty_paths\Functional

Code

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

  /** @var \Drupal\facets\FacetInterface $facet */
  $facet = $this->container
    ->get('entity_type.manager')
    ->getStorage('facets_facet')
    ->load('content_type');
  $facet
    ->setThirdPartySetting('facets_pretty_paths', 'coder', 'dummy_coder');
  $facet
    ->save();
  $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/dummy-article', $urls[0]
    ->getRouteParameters()['facets_query']);
  $this
    ->assertEquals('content_type/dummy-page', $urls[1]
    ->getRouteParameters()['facets_query']);
}