You are here

public function IntegrationTest::testOnViewRemoval in Facets 8

Tests what happens when a dependency is removed.

File

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

Class

IntegrationTest
Tests the overall functionality of the Facets admin UI.

Namespace

Drupal\Tests\facets\Functional

Code

public function testOnViewRemoval() {
  $id = "owl";
  $name = "Owl";
  $this
    ->createFacet($name, $id);
  $this
    ->drupalGet('/admin/config/search/facets');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Check that the expected facet sources and the owl facet are shown.
  $this
    ->assertSession()
    ->pageTextContains('search_api:views_block__search_api_test_view__block_1');
  $this
    ->assertSession()
    ->pageTextContains('search_api:views_page__search_api_test_view__page_1');
  $this
    ->assertSession()
    ->pageTextContains($name);

  // Delete the view on which both facet sources are based.
  $view = View::load('search_api_test_view');
  $view
    ->delete();

  // Go back to the overview, make sure that the page doesn't show any errors
  // and the facet/facet source are deleted.
  $this
    ->drupalGet('/admin/config/search/facets');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextNotContains('search_api:views_page__search_api_test_view__page_1');
  $this
    ->assertSession()
    ->pageTextNotContains('search_api:views_block__search_api_test_view__block_1');
  $this
    ->assertSession()
    ->pageTextNotContains($name);
}