class NodeRevisionsUiBypassAccessTest
Same name and namespace in other branches
- 11.x core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php \Drupal\Tests\node\Functional\NodeRevisionsUiBypassAccessTest
- 10 core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php \Drupal\Tests\node\Functional\NodeRevisionsUiBypassAccessTest
- 8.9.x core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php \Drupal\Tests\node\Functional\NodeRevisionsUiBypassAccessTest
Tests the revision tab display.
This test is similar to NodeRevisionsUITest except that it uses a user with the bypass node access permission to make sure that the revision access check adds correct cacheability metadata.
@group node
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\node\Functional\NodeTestBase extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\node\Functional\NodeRevisionsUiBypassAccessTest extends \Drupal\Tests\node\Functional\NodeTestBase
- class \Drupal\Tests\node\Functional\NodeTestBase extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of NodeRevisionsUiBypassAccessTest
File
-
core/
modules/ node/ tests/ src/ Functional/ NodeRevisionsUiBypassAccessTest.php, line 16
Namespace
Drupal\Tests\node\FunctionalView source
class NodeRevisionsUiBypassAccessTest extends NodeTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* User with bypass node access permission.
*
* @var \Drupal\user\Entity\User
*/
protected $editor;
/**
* {@inheritdoc}
*/
protected static $modules = [
'block',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
// Create a user.
$this->editor = $this->drupalCreateUser([
'administer nodes',
'edit any page content',
'view page revisions',
'bypass node access',
'access user profiles',
]);
}
/**
* Checks that the Revision tab is displayed correctly.
*/
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.