function NodeRevisionsUiBypassAccessTest::testDisplayRevisionTab

Same name in other branches
  1. 8.9.x core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php \Drupal\Tests\node\Functional\NodeRevisionsUiBypassAccessTest::testDisplayRevisionTab()
  2. 10 core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php \Drupal\Tests\node\Functional\NodeRevisionsUiBypassAccessTest::testDisplayRevisionTab()
  3. 11.x core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php \Drupal\Tests\node\Functional\NodeRevisionsUiBypassAccessTest::testDisplayRevisionTab()

Checks that the Revision tab is displayed correctly.

File

core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php, line 54

Class

NodeRevisionsUiBypassAccessTest
Tests the revision tab display.

Namespace

Drupal\Tests\node\Functional

Code

public function testDisplayRevisionTab() {
    $this->drupalPlaceBlock('local_tasks_block');
    $this->drupalLogin($this->editor);
    // Set page revision setting 'create new revision'. This will mean new
    // revisions are created by default when the node is edited.
    $type = NodeType::load('page');
    $type->setNewRevision(TRUE);
    $type->save();
    // Create the node.
    $node = $this->drupalCreateNode();
    // Verify the checkbox is checked on the node edit form.
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->assertSession()
        ->checkboxChecked('edit-revision');
    // Uncheck the create new revision checkbox and save the node.
    $edit = [
        'revision' => FALSE,
    ];
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm($edit, 'Save');
    $this->assertSession()
        ->addressEquals($node->toUrl());
    // Verify revisions exist.
    $this->assertSession()
        ->linkExists('Revisions');
    // Verify the checkbox is checked on the node edit form.
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->assertSession()
        ->checkboxChecked('edit-revision');
    // Submit the form without changing the checkbox.
    $edit = [];
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm($edit, 'Save');
    $this->assertSession()
        ->addressEquals($node->toUrl());
    $this->assertSession()
        ->linkExists('Revisions');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.