public function CoreViewsIntegrationTest::testFramework in Core Views Facets 8
Tests various operations via the Facets' admin UI.
File
- tests/
src/ Functional/ CoreViewsIntegrationTest.php, line 114
Class
- CoreViewsIntegrationTest
- Tests the overall functionality of the Facets admin UI.
Namespace
Drupal\Tests\core_views_facets\FunctionalCode
public function testFramework() {
$facet_name = "Test Facet name";
$facet_id = 'test_facet_name';
// Check if the overview is empty.
$this
->checkEmptyOverview();
// Add a new facet and edit it. Check adding a duplicate.
$this
->addFacet($facet_name);
$this
->editFacet($facet_name);
// By default, the view should show all entities.
$this
->drupalGet($this->facetUrl);
$this
->assertSession()
->pageTextContains('Displaying 5 search results');
// Create and place a block for "Test Facet name" facet.
$this->blocks[$facet_id] = $this
->createBlock($facet_id);
// Verify that the facet results are correct.
$this
->drupalGet($this->facetUrl);
$this
->assertSession()
->pageTextContains('item');
$this
->assertSession()
->pageTextContains('article');
// Verify that facet blocks appear as expected.
$this
->assertFacetBlocksAppear();
// Verify that the facet only shows when the facet source is visible, it
// should not show up on the user page.
$this
->setOptionShowOnlyWhenFacetSourceVisible($facet_name);
$this
->drupalGet('user/2');
$this
->assertNoFacetBlocksAppear();
$content_ids = \Drupal::entityQuery('entity_test')
->execute();
$storage = \Drupal::entityTypeManager()
->getStorage('entity_test');
$entities = $storage
->loadMultiple($content_ids);
$storage
->delete($entities);
// Do not show the block on empty behaviors.
$this
->drupalGet($this->facetUrl);
// Verify that no facet blocks appear. Empty behavior "None" is selected by
// default.
$this
->assertNoFacetBlocksAppear();
// Verify that the "empty_text" appears as expected.
$this
->setEmptyBehaviorFacetText($facet_name);
$this
->drupalGet($this->facetUrl);
$this
->assertSession()
->responseContains('block-test-facet-name');
$this
->assertSession()
->responseContains('No results found for this block!');
}