diff -u b/core/modules/node/src/Tests/Views/RevisionLinkTest.php b/core/modules/node/src/Tests/Views/RevisionLinkTest.php --- b/core/modules/node/src/Tests/Views/RevisionLinkTest.php +++ b/core/modules/node/src/Tests/Views/RevisionLinkTest.php @@ -1,10 +1,5 @@ drupalCreateContentType(array('name' => 'page', 'type' => 'page')); - $account = $this->drupalCreateUser(array('revert all revisions', 'view all revisions', 'delete all revisions', 'edit any page content', 'delete any page content')); + $this->drupalCreateContentType(['name' => 'page', 'type' => 'page']); + $account = $this->drupalCreateUser(['revert all revisions', 'view all revisions', 'delete all revisions', 'edit any page content', 'delete any page content']); $this->drupalLogin($account); // Create two nodes, one without an additional revision and one with a // revision. - $node = $this->drupalCreateNode(); - $this->nodes[] = $node; - $node = $this->drupalCreateNode(); - $this->nodes[] = $node; + $nodes = [ + $this->drupalCreateNode(), + $this->drupalCreateNode(), + ]; - $first_revision = $node->getRevisionId(); + $first_revision = $nodes[1]->getRevisionId(); // Create revision of the node. - $node->setNewRevision(); - $node->save(); - $second_revision = $node->getRevisionId(); + $nodes[1]->setNewRevision(); + $nodes[1]->save(); + $second_revision = $nodes[1]->getRevisionId(); $this->drupalGet('test-node-revision-links'); $this->assertResponse(200, 'Test view can be accessed in the path expected'); // The first node revision should link to the node directly as you get an // access denied if you link to the revision. - $url = $this->nodes[0]->urlInfo()->toString(); + $url = $nodes[0]->urlInfo()->toString(); $this->assertLinkByHref($url); - $this->assertNoLinkByHref($url . '/revisions/' . $this->nodes[0]->getRevisionId() . '/delete'); - $this->assertNoLinkByHref($url . '/revisions/' . $this->nodes[0]->getRevisionId() . '/revert'); + $this->assertNoLinkByHref($url . '/revisions/' . $nodes[0]->getRevisionId() . '/view'); + $this->assertNoLinkByHref($url . '/revisions/' . $nodes[0]->getRevisionId() . '/delete'); + $this->assertNoLinkByHref($url . '/revisions/' . $nodes[0]->getRevisionId() . '/revert'); // For the second node the current revision got set to the last revision, so // the first one should also link to the node page itself. - $url = $this->nodes[1]->urlInfo()->toString(); + $url = $nodes[1]->urlInfo()->toString(); + $this->assertLinkByHref($url); $this->assertLinkByHref($url . '/revisions/' . $first_revision . '/view'); $this->assertLinkByHref($url . '/revisions/' . $first_revision . '/delete'); $this->assertLinkByHref($url . '/revisions/' . $first_revision . '/revert'); - - $this->assertLinkByHref($url); $this->assertNoLinkByHref($url . '/revisions/' . $second_revision . '/view'); $this->assertNoLinkByHref($url . '/revisions/' . $second_revision . '/delete'); $this->assertNoLinkByHref($url . '/revisions/' . $second_revision . '/revert'); - $accounts = array(); - $accounts['view'] = $this->drupalCreateUser(array('view all revisions')); - $accounts['revert'] = $this->drupalCreateUser(array('revert all revisions', 'edit any page content')); - $accounts['delete'] = $this->drupalCreateUser(array('delete all revisions', 'delete any page content')); - $operations = array_keys($accounts); - array_shift($operations); - $url = $this->nodes[1]->urlInfo()->toString(); + $accounts = [ + 'view' => $this->drupalCreateUser(['view all revisions']), + 'revert' => $this->drupalCreateUser(['revert all revisions', 'edit any page content']), + 'delete' => $this->drupalCreateUser(['delete all revisions', 'delete any page content']), + ]; + + $url = $nodes[1]->urlInfo()->toString(); // Render the view with users which can only delete/revert revisions. - foreach ($accounts as $op => $account) { + foreach ($accounts as $allowed_operation => $account) { $this->drupalLogin($account); $this->drupalGet('test-node-revision-links'); // Check expected links. - foreach ($operations as $operation) { - if ($operation == $op) { + foreach (['revert', 'delete'] as $operation) { + if ($operation == $allowed_operation) { $this->assertLinkByHref($url . '/revisions/' . $first_revision . '/' . $operation); } else {