ViewsBulkTest.php in Drupal 10
File
core/modules/views/tests/src/Functional/Plugin/ViewsBulkTest.php
View source
<?php
namespace Drupal\Tests\views\Functional\Plugin;
use Drupal\Tests\views\Functional\ViewTestBase;
class ViewsBulkTest extends ViewTestBase {
protected $admin_user;
protected static $modules = [
'node',
'views',
];
protected $defaultTheme = 'stark';
protected function setUp($import_test_views = TRUE, $modules = [
'views_test_config',
]) : void {
parent::setUp($import_test_views, $modules);
$this
->drupalCreateContentType([
'type' => 'page',
]);
$this->admin_user = $this
->createUser([
'bypass node access',
'administer nodes',
'access content overview',
]);
}
public function testBulkSelection() {
$node_1 = $this
->drupalCreateNode([
'type' => 'page',
'title' => 'The first node',
'changed' => \Drupal::time()
->getRequestTime() - 180,
]);
$this
->drupalLogin($this->admin_user);
$this
->drupalGet('admin/content');
$this
->assertSession()
->pageTextContains($node_1
->getTitle());
$node_2 = $this
->drupalCreateNode([
'type' => 'page',
'title' => 'The second node',
'changed' => \Drupal::time()
->getRequestTime() - 120,
]);
$this
->submitForm([
'node_bulk_form[0]' => TRUE,
], 'Apply to selected items');
$this
->assertSession()
->pageTextContains($node_1
->getTitle());
$this
->assertSession()
->pageTextNotContains($node_2
->getTitle());
$this
->config('views.view.content')
->set('display.default.display_options.pager.options.items_per_page', 2)
->save();
$this
->drupalGet('admin/content');
$node_3 = $this
->drupalCreateNode([
'type' => 'page',
'title' => 'The third node',
]);
$this
->submitForm([
'node_bulk_form[1]' => TRUE,
], 'Apply to selected items');
$this
->assertSession()
->pageTextContains($node_1
->getTitle());
$this
->assertSession()
->pageTextNotContains($node_3
->getTitle());
}
}