function NodeDeleteConfirmTest::testNodeTypeDelete

Same name and namespace in other branches
  1. 11.x core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php \Drupal\Tests\node\FunctionalJavascript\NodeDeleteConfirmTest::testNodeTypeDelete()
  2. 10 core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php \Drupal\Tests\node\FunctionalJavascript\NodeDeleteConfirmTest::testNodeTypeDelete()

Tests that the node type delete operation opens in a modal.

File

core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php, line 115

Class

NodeDeleteConfirmTest
Tests JavaScript functionality specific to delete operations.

Namespace

Drupal\Tests\node\FunctionalJavascript

Code

public function testNodeTypeDelete() : void {
  $page = $this->getSession()
    ->getPage();
  // Delete node type using link on the content type list.
  $this->drupalGet('admin/structure/types');
  $this->assertSession()
    ->waitForText('Article');
  $page->find('css', '.dropbutton-toggle button')
    ->click();
  $this->clickLink('Delete');
  $this->assertEquals('Are you sure you want to delete the content type Article?', $this->assertSession()
    ->waitForElement('css', '.ui-dialog-title')
    ->getText());
  $page->find('css', '.ui-dialog-buttonset')
    ->pressButton('Delete');
  $this->assertSession()
    ->pageTextContains('The content type Article has been deleted.');
  $this->drupalCreateContentType([
    'name' => 'Article',
    'type' => 'article',
  ]);
  // Delete node type using link on the edit content type form.
  $this->drupalGet('admin/structure/types/manage/article');
  $this->clickLink('Delete');
  $this->assertEquals('Are you sure you want to delete the content type Article?', $this->assertSession()
    ->waitForElement('css', '.ui-dialog-title')
    ->getText());
  $page->find('css', '.ui-dialog-buttonset')
    ->pressButton('Delete');
  $this->assertSession()
    ->pageTextContains('The content type Article has been deleted.');
}

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