You are here

public function IntegrationTest::testFramework in Facets 8

Same name in this branch
  1. 8 tests/src/Functional/IntegrationTest.php \Drupal\Tests\facets\Functional\IntegrationTest::testFramework()
  2. 8 modules/facets_summary/tests/src/Functional/IntegrationTest.php \Drupal\Tests\facets_summary\Functional\IntegrationTest::testFramework()

Tests various operations via the Facets' admin UI.

File

tests/src/Functional/IntegrationTest.php, line 78

Class

IntegrationTest
Tests the overall functionality of the Facets admin UI.

Namespace

Drupal\Tests\facets\Functional

Code

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);
  $this
    ->addFacetDuplicate($facet_name);

  // By default, the view should show all entities.
  $this
    ->drupalGet('search-api-test-fulltext');
  $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('search-api-test-fulltext');
  $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();

  // Do not show the block on empty behaviors.
  $this
    ->clearIndex();
  $this
    ->drupalGet('search-api-test-fulltext');

  // 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('search-api-test-fulltext');
  $this
    ->assertSession()
    ->responseContains('block-test-facet-name');
  $this
    ->assertSession()
    ->responseContains('No results found for this block!');

  // Delete the block.
  $this
    ->deleteBlock($facet_id);

  // Delete the facet and make sure the overview is empty again.
  $this
    ->deleteUnusedFacet($facet_name);
  $this
    ->checkEmptyOverview();
}