function ViewEditTest::testDeleteLink

Same name in other branches
  1. 9 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(t('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(t('Delete view'));
    $this->assertUrl('admin/structure/views/view/test_view/delete');
    $this->drupalPostForm(NULL, [], t('Delete'));
    $this->assertRaw(t('The view %name has been deleted.', [
        '%name' => $view->label(),
    ]));
    $this->assertUrl('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.