You are here

public function ActiveFiltersTest::testEncodedActiveFilters in Facets Pretty Paths 8

Tests that the coder plugins successfully decode the filters.

File

tests/src/Kernel/ActiveFiltersTest.php, line 69

Class

ActiveFiltersTest
Tests the active filter service.

Namespace

Drupal\Tests\facets_pretty_paths\Kernel

Code

public function testEncodedActiveFilters() {

  /** @var \Drupal\facets\FacetInterface $facet */
  $facet = $this->container
    ->get('entity_type.manager')
    ->getStorage('facets_facet')
    ->load('content_type');
  $this
    ->assertInstanceOf(Facet::class, $facet);
  $facet
    ->setThirdPartySetting('facets_pretty_paths', 'coder', 'dummy_coder');
  $facet
    ->save();

  // This doesn't actually exist but it's the one our test facet uses.
  $source_id = 'search_api:views_page__search__page_1';
  $stack = $this->container
    ->get('request_stack');

  // Push a dummy request to the stack.
  $this
    ->pushRequest($stack, 'My search page', 'content_type/dummy-article/content_type/dummy-page/content_type/dummy-dummy');

  /** @var \Drupal\facets_pretty_paths\PrettyPathsActiveFilters $active_filters_service */
  $active_filters_service = $this->container
    ->get('facets_pretty_paths.active_filters');
  $active_filters = $active_filters_service
    ->getActiveFilters($source_id);
  $this
    ->assertEquals([
    'content_type' => [
      'article',
      'page',
      'dummy',
    ],
  ], $active_filters);
}