You are here

public function IntegrationTest::testOnViewDisplayRemoval in Facets 8

Tests what happens when a dependency is removed.

File

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

Class

IntegrationTest
Tests the overall functionality of the Facets admin UI.

Namespace

Drupal\Tests\facets\Functional

Code

public function testOnViewDisplayRemoval() {
  $admin_user = $this
    ->drupalCreateUser([
    'administer search_api',
    'administer facets',
    'access administration pages',
    'administer nodes',
    'access content overview',
    'administer content types',
    'administer blocks',
    'administer views',
  ]);
  $this
    ->drupalLogin($admin_user);
  $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 display for the page.
  $this
    ->drupalGet('admin/structure/views/view/search_api_test_view');
  $this
    ->drupalPostForm(NULL, [], 'Delete Page');
  $this
    ->drupalPostForm(NULL, [], 'Save');

  // 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()
    ->pageTextContains('search_api:views_block__search_api_test_view__block_1');
  $this
    ->assertSession()
    ->pageTextNotContains($name);
}