diff --git a/core/modules/node/src/Tests/NodeRevisionsAllTest.php b/core/modules/node/src/Tests/NodeRevisionsAllTest.php index 582ca5b..380b1ae 100644 --- a/core/modules/node/src/Tests/NodeRevisionsAllTest.php +++ b/core/modules/node/src/Tests/NodeRevisionsAllTest.php @@ -2,6 +2,8 @@ namespace Drupal\node\Tests; +use Drupal\node\NodeInterface; + /** * Create a node with revisions and test viewing, saving, reverting, and * deleting revisions for user with access to all. @@ -15,7 +17,7 @@ class NodeRevisionsAllTest extends NodeTestBase { protected function setUp() { parent::setUp(); - $node_storage = $this->container->get('entity.manager')->getStorage('node'); + // Create and log in user. $web_user = $this->drupalCreateUser( array( @@ -45,17 +47,7 @@ protected function setUp() { for ($i = 0; $i < $revision_count; $i++) { $logs[] = $node->revision_log = $this->randomMachineName(32); - // Create revision with a random title and body and update variables. - $node->title = $this->randomMachineName(); - $node->body = array( - 'value' => $this->randomMachineName(32), - 'format' => filter_default_format(), - ); - $node->setNewRevision(); - $node->save(); - - $node_storage->resetCache(array($node->id())); - $node = $node_storage->load($node->id()); // Make sure we get revision information. + $node = $this->createNodeRevision($node); $nodes[] = clone $node; } @@ -64,6 +56,33 @@ protected function setUp() { } /** + * Creates a new revision for a given node. + * + * @param \Drupal\node\NodeInterface $node + * A node object. + * + * @return \Drupal\node\NodeInterface + * A node object with up to date revision information. + */ + protected function createNodeRevision(NodeInterface $node) { + $node_storage = $this->container->get('entity.manager')->getStorage('node'); + + // Create revision with a random title and body and update variables. + $node->title = $this->randomMachineName(); + $node->body = array( + 'value' => $this->randomMachineName(32), + 'format' => filter_default_format(), + ); + $node->setNewRevision(); + $node->save(); + + $node_storage->resetCache(array($node->id())); + + // Make sure we get revision information. + return $node_storage->load($node->id()); + } + + /** * Checks node revision operations. */ function testRevisions() { @@ -145,6 +164,29 @@ function testRevisions() { '%title' => $nodes[2]->getTitle(), '%revision-date' => format_date($old_revision_date), ))); + + // Create 50 more revisions in order to trigger paging on the revisions + // overview screen. + $node = $nodes[0]; + for ($i = 0; $i < 50; $i++) { + $logs[] = $node->revision_log = $this->randomMachineName(32); + + $node = $this->createNodeRevision($node); + $nodes[] = clone $node; + } + + $this->drupalGet('node/' . $node->id() . '/revisions'); + + // Check that the pager exists. + $this->assertRaw('page=1'); + + // Check that the last revision is displayed on the first page. + $this->assertText(end($logs)); + + // Go to the second page and check that one of the initial three revisions + // is displayed. + $this->clickLink(t('Page 2')); + $this->assertText($logs[2]); } }