public function ViewsBulkEditActionTest::testViewsBulkEdit in Views Bulk Edit 8.2
Test VBE from the UI using the node module.
File
- tests/
src/ Functional/ ViewsBulkEditActionTest.php, line 62
Class
- ViewsBulkEditActionTest
- Tests the core edit action.
Namespace
Drupal\Tests\views_bulk_edit\FunctionalCode
public function testViewsBulkEdit() {
$storage = $this->container
->get('entity_type.manager')
->getStorage('node');
$page1 = $this
->createNode();
$page2 = $this
->createNode();
$article1 = $this
->createNode([
'type' => 'article',
]);
// Test editing a single article with properties and fields.
$this
->drupalGet('test-node-bulk-form');
$this
->submitForm([
'action' => 'node_edit_action',
'node_bulk_form[0]' => TRUE,
'node_bulk_form[1]' => TRUE,
], 'Apply to selected items');
$random_title = $this
->randomMachineName();
// Ensure that non configurable form fields do not appear.
$this
->assertSession()
->fieldNotExists('node[page][_field_selector][revision_log]');
$this
->submitForm([
'node[page][_field_selector][title]' => '1',
'node[page][title][0][value]' => $random_title,
], 'Confirm');
// Assert property was changes. Assert field was changed.
$storage
->resetCache();
$nodes = array_values($storage
->loadMultiple([
$page1
->id(),
$page2
->id(),
$article1
->id(),
]));
$this
->assertEquals($random_title, $nodes[0]
->getTitle());
$this
->assertEquals($random_title, $nodes[1]
->getTitle());
$this
->assertNotEquals($random_title, $nodes[2]
->getTitle());
}