function ViewEditTest::testDeleteLink

Same name in other branches
  1. 8.9.x core/modules/views_ui/tests/src/Functional/ViewEditTest.php \Drupal\Tests\views_ui\Functional\ViewEditTest::testDeleteLink()
  2. 10 core/modules/views_ui/tests/src/Functional/ViewEditTest.php \Drupal\Tests\views_ui\Functional\ViewEditTest::testDeleteLink()
  3. 11.x 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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.