You are here

public function ViewsBulkEditActionTest::testRevisionUi in Views Bulk Edit 8.2

Test the revision UI.

File

tests/src/Functional/ViewsBulkEditActionTest.php, line 152

Class

ViewsBulkEditActionTest
Tests the core edit action.

Namespace

Drupal\Tests\views_bulk_edit\Functional

Code

public function testRevisionUi() {
  $page1 = $this
    ->createNode();
  $this
    ->drupalGet('test-node-bulk-form');
  $this
    ->submitForm([
    'action' => 'node_edit_action',
    'node_bulk_form[0]' => TRUE,
  ], 'Apply to selected items');
  $random_title = $this
    ->randomMachineName();
  $storage = $this->container
    ->get('entity_type.manager')
    ->getStorage('node');
  $latestes_revision = $page1
    ->getRevisionId();
  $this
    ->submitForm([
    'node[page][_field_selector][title]' => '1',
    'node[page][title][0][value]' => $random_title,
    'node[page][revision_information][revision]' => FALSE,
  ], 'Confirm');
  $storage
    ->resetCache();
  $page1 = $storage
    ->load($page1
    ->id());
  $this
    ->assertEquals($random_title, $page1
    ->getTitle());

  // No new revision was created.
  $this
    ->assertEquals($latestes_revision, $page1
    ->getRevisionId());
  $this
    ->drupalGet('test-node-bulk-form');
  $this
    ->submitForm([
    'action' => 'node_edit_action',
    'node_bulk_form[0]' => TRUE,
  ], 'Apply to selected items');
  $random_title = $this
    ->randomMachineName();
  $this
    ->submitForm([
    'node[page][_field_selector][title]' => '1',
    'node[page][title][0][value]' => $random_title,
    'node[page][revision_information][revision]' => TRUE,
    'node[page][revision_information][revision_log]' => 'My new revision',
  ], 'Confirm');
  $storage
    ->resetCache();
  $page1 = $storage
    ->load($page1
    ->id());
  $this
    ->assertEquals($random_title, $page1
    ->getTitle());
  $this
    ->assertNotEquals($latestes_revision, $page1
    ->getRevisionId());
  $this
    ->assertEquals('My new revision', $page1
    ->getRevisionLogMessage());
}