Namespace
Drupal\Tests\node\FunctionalJavascript
File
core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\node\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class NodeDeleteConfirmTest extends WebDriverTestBase {
protected $defaultTheme = 'stark';
protected static $modules = [
'node',
];
protected function setUp() : void {
parent::setUp();
$this
->drupalCreateContentType([
'name' => 'Article',
'type' => 'article',
]);
$admin_user = $this
->drupalCreateUser([
'access content',
'access content overview',
'administer content types',
'edit any article content',
'delete any article content',
]);
$this
->drupalLogin($admin_user);
}
public function testNodeDelete() {
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$node = $this
->createNode([
'type' => 'article',
'title' => 'Delete article from content list',
]);
$node
->save();
$this
->drupalGet('admin/content');
$page
->find('css', '.dropbutton-toggle button')
->click();
$page
->clickLink('Delete');
$this
->assertEquals('Are you sure you want to delete the content item Delete article from content list?', $assert_session
->waitForElement('css', '.ui-dialog-title')
->getText());
$page
->find('css', '.ui-dialog-buttonset')
->pressButton('Delete');
$assert_session
->waitForText('The Article Delete article from content list has been deleted.');
$this
->drupalGet('/admin/content');
$assert_session
->waitForText('There are no content items yet.');
$node = $this
->createNode([
'type' => 'article',
'title' => 'Delete article from entity form',
]);
$node
->save();
$this
->drupalGet('node/2/edit');
$this
->clickLink('Delete');
$this
->assertEquals('Are you sure you want to delete the content item Delete article from entity form?', $assert_session
->waitForElement('css', '.ui-dialog-title')
->getText());
$page
->find('css', '.ui-dialog-buttonset')
->pressButton('Delete');
$this
->assertSession()
->pageTextContains('The Article Delete article from entity form has been deleted.');
$this
->drupalGet('/admin/content');
$assert_session
->waitForText('There are no content items yet.');
}
public function testNodeTypeDelete() {
$page = $this
->getSession()
->getPage();
$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',
]);
$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.');
}
}
Classes