protected function NodeRevisionsAllTest::setUp in Drupal 8
Same name and namespace in other branches
- 9 core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php \Drupal\Tests\node\Functional\NodeRevisionsAllTest::setUp()
Overrides NodeTestBase::setUp
File
- core/
modules/ node/ tests/ src/ Functional/ NodeRevisionsAllTest.php, line 45
Class
- NodeRevisionsAllTest
- Create a node with revisions and test viewing, saving, reverting, and deleting revisions for user with access to all.
Namespace
Drupal\Tests\node\FunctionalCode
protected function setUp() {
parent::setUp();
// Create and log in user.
$web_user = $this
->drupalCreateUser([
'view page revisions',
'revert page revisions',
'delete page revisions',
'edit any page content',
'delete any page content',
]);
$this
->drupalLogin($web_user);
// Create an initial node.
$node = $this
->drupalCreateNode();
// Create a user for revision authoring.
// This must be different from user performing revert.
$this->revisionUser = $this
->drupalCreateUser();
$settings = get_object_vars($node);
$settings['revision'] = 1;
$nodes = [];
$logs = [];
// Get the original node.
$nodes[] = clone $node;
// Create three revisions.
$revision_count = 3;
for ($i = 0; $i < $revision_count; $i++) {
$logs[] = $node->revision_log = $this
->randomMachineName(32);
$node = $this
->createNodeRevision($node);
$nodes[] = clone $node;
}
$this->nodes = $nodes;
$this->revisionLogs = $logs;
}