public function ActiveFiltersTest::testDefaultActiveFilters in Facets Pretty Paths 8
Tests the service responsible for determining the active filters.
File
- tests/
src/ Kernel/ ActiveFiltersTest.php, line 40
Class
- ActiveFiltersTest
- Tests the active filter service.
Namespace
Drupal\Tests\facets_pretty_paths\KernelCode
public function testDefaultActiveFilters() {
$facet = $this->container
->get('entity_type.manager')
->getStorage('facets_facet')
->load('content_type');
// The facet should get imported from the optional test module config as
// it no longer has dependencies.
$this
->assertInstanceOf(Facet::class, $facet);
// 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/article/content_type/page/content_type/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);
}