You are here

public function ViewEditTest::testDeleteLink in Drupal 8

Same name and namespace 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()

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);
}