Namespace
Drupal\Tests\views\FunctionalJavascript\Plugin
File
core/modules/views/tests/src/FunctionalJavascript/Plugin/BulkOperationsTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\views\FunctionalJavascript\Plugin;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class BulkOperationsTest extends WebDriverTestBase {
protected static $modules = [
'node',
'views',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
\Drupal::configFactory()
->getEditable('views.view.content')
->set('display.default.display_options.use_ajax', TRUE)
->save();
$this
->drupalCreateContentType([
'type' => 'page',
]);
$this
->drupalLogin($this
->createUser([
'bypass node access',
'administer nodes',
'access content overview',
]));
}
public function testBulkOperations() {
$node_1 = $this
->drupalCreateNode([
'type' => 'page',
'title' => 'The first node',
'changed' => \Drupal::time()
->getRequestTime() - 180,
]);
$node_2 = $this
->drupalCreateNode([
'type' => 'page',
'title' => 'The second node',
'changed' => \Drupal::time()
->getRequestTime() - 120,
]);
$this
->drupalGet('admin/content');
$this
->assertSession()
->pageTextContains($node_1
->getTitle());
$this
->assertSession()
->pageTextContains($node_1
->getTitle());
$this
->assertSession()
->pageTextContains($node_2
->getTitle());
$this
->submitForm([
'title' => 'The first node',
], 'Filter');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assertSession()
->pageTextContains($node_1
->getTitle());
$this
->assertSession()
->pageTextNotContains($node_2
->getTitle());
$action_select = $this
->getSession()
->getPage()
->find('css', '[data-drupal-selector="edit-action"]');
$action_select_name = $action_select
->getAttribute('name');
$this
->getSession()
->getPage()
->selectFieldOption($action_select_name, 'node_delete_action');
$this
->submitForm([
'node_bulk_form[0]' => TRUE,
], 'Apply to selected items');
$this
->assertSession()
->pageTextContains($node_1
->getTitle());
$this
->assertSession()
->pageTextNotContains($node_2
->getTitle());
$this
->getSession()
->getPage()
->pressButton('Delete');
$this
->assertSession()
->pageTextNotContains($node_1
->getTitle());
$this
->assertSession()
->pageTextNotContains($node_2
->getTitle());
$this
->assertSession()
->responseContains('/core/misc/ajax.js');
$this
->submitForm([], 'Reset');
$this
->assertSession()
->pageTextContains($node_2
->getTitle());
$action_select = $this
->getSession()
->getPage()
->find('css', '[data-drupal-selector="edit-action"]');
$action_select_name = $action_select
->getAttribute('name');
$this
->getSession()
->getPage()
->selectFieldOption($action_select_name, 'node_unpublish_action');
$this
->assertSession()
->responseContains('/core/misc/ajax.js');
}
}
Classes