You are here

public function ViewEditTest::testDeleteLink in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views_ui/tests/src/Functional/ViewEditTest.php \Drupal\Tests\views_ui\Functional\ViewEditTest::testDeleteLink()
  2. 9 core/modules/views_ui/tests/src/Functional/ViewEditTest.php \Drupal\Tests\views_ui\Functional\ViewEditTest::testDeleteLink()

Tests the delete link on a views UI.

File

core/modules/views_ui/tests/src/Functional/ViewEditTest.php, line 30

Class

ViewEditTest
Tests some general functionality of editing views, like deleting a view.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testDeleteLink() {
  $this
    ->drupalGet('admin/structure/views/view/test_view');
  $this
    ->assertSession()
    ->linkExists('Delete view', 0, 'Ensure that the view delete link appears');
  $view = $this->container
    ->get('entity_type.manager')
    ->getStorage('view')
    ->load('test_view');
  $this
    ->assertInstanceOf(View::class, $view);
  $this
    ->clickLink('Delete view');
  $this
    ->assertSession()
    ->addressEquals('admin/structure/views/view/test_view/delete');
  $this
    ->submitForm([], 'Delete');
  $this
    ->assertSession()
    ->pageTextContains("The view {$view->label()} has been deleted.");
  $this
    ->assertSession()
    ->addressEquals('admin/structure/views');
  $view = $this->container
    ->get('entity_type.manager')
    ->getStorage('view')
    ->load('test_view');
  $this
    ->assertNotInstanceOf(View::class, $view);
}