diff --git a/src/Tests/IntegrationTest.php b/src/Tests/IntegrationTest.php index f534131..c2af8b7 100644 --- a/src/Tests/IntegrationTest.php +++ b/src/Tests/IntegrationTest.php @@ -122,6 +122,53 @@ class IntegrationTest extends FacetWebTestBase { } /** + * Tests that a block view also works. + */ + public function testBlockView() { + $facet_name = "Block view facet"; + $facet_id = 'bvf'; + + // Add a new facet. + $facet_add_page = '/admin/config/search/facets/add-facet'; + $this->drupalGet($facet_add_page); + + $form_values = [ + 'id' => $facet_id, + 'status' => 1, + 'url_alias' => $facet_id, + 'name' => $facet_name, + 'facet_source_id' => 'search_api_views:search_api_test_view:block_1', + 'facet_source_configs[search_api_views:search_api_test_view:block_1][field_identifier]' => 'type', + ]; + $this->drupalPostForm(NULL, ['facet_source_id' => 'search_api_views:search_api_test_view:block_1'], $this->t('Configure facet source')); + $this->drupalPostForm(NULL, $form_values, $this->t('Save')); + + // Place the views block in the footer of all pages. + $block_settings = [ + 'region' => 'footer', + 'id' => 'view_block', + ]; + $this->drupalPlaceBlock('views_block:search_api_test_view-block_1', $block_settings); + + // By default, the view should show all entities. + $this->drupalGet(''); + $this->assertText('Displaying 5 search results', 'The search view displays the correct number of results.'); + $this->assertText('Fulltext test index', 'The search view displays the correct number of results.'); + + // Create and place a block for the test facet. + $this->createFacetBlock($facet_id); + + // Verify that the facet results are correct displayed. + $this->drupalGet(''); + $this->assertText('item'); + $this->assertText('article'); + + // Click the item link, and test that filtering of results actually works. + $this->clickLink('item'); + $this->assertText('Displaying 3 search results', 'The search view displays the correct number of results.'); + } + + /** * Tests renaming of a facet. * * @see https://www.drupal.org/node/2629504 @@ -591,6 +638,10 @@ class IntegrationTest extends FacetWebTestBase { // The list overview has Field: field_name as description. This tests on the // absence of that. $this->assertNoText('Field:'); + + // Check that the expected facet sources are shown. + $this->assertText('search_api_views:search_api_test_view:block_1'); + $this->assertText('search_api_views:search_api_test_view:page_1'); } /** diff --git a/tests/facets_search_api_dependency/config/install/views.view.search_api_test_views_fulltext.yml b/tests/facets_search_api_dependency/config/install/views.view.search_api_test_views_fulltext.yml index 976a8d8..2ee43bc 100644 --- a/tests/facets_search_api_dependency/config/install/views.view.search_api_test_views_fulltext.yml +++ b/tests/facets_search_api_dependency/config/install/views.view.search_api_test_views_fulltext.yml @@ -187,6 +187,13 @@ display: position: 1 display_options: path: search-api-test-fulltext + block_1: + display_plugin: block + id: block_1 + display_title: Block + position: 2 + display_options: + display_extenders: { } label: 'Search API Test Fulltext search view' module: views id: search_api_test_view