function NodeRevisionsUiTest::testNodeRevisionsTabPagerAffectedTranslations
Same name and namespace in other branches
- 11.x core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php \Drupal\Tests\node\Functional\NodeRevisionsUiTest::testNodeRevisionsTabPagerAffectedTranslations()
Tests the revision tab paginates correctly with affected translations.
File
-
core/
modules/ node/ tests/ src/ Functional/ NodeRevisionsUiTest.php, line 195
Class
- NodeRevisionsUiTest
- Tests the UI for controlling node revision behavior.
Namespace
Drupal\Tests\node\FunctionalCode
public function testNodeRevisionsTabPagerAffectedTranslations() : void {
$this->drupalLogin($this->editor);
$node = $this->drupalCreateNode();
// Create 49 revisions with translation changes so there are a total of 50
// including the initial revision.
for ($i = 1; $i < 50; $i++) {
$node->setTitle($this->randomString())
->setRevisionLogMessage('translation change ' . $i);
$node->isDefaultRevision(FALSE);
$node->setNewRevision(TRUE);
$node->save();
}
// Create 50 revisions without translation changes.
for ($i = 0; $i < 50; $i++) {
$node->isDefaultRevision(FALSE);
$node->setNewRevision(TRUE);
$node->save();
}
// There should be the initial 50 revisions and no pager as the
// non-affecting revisions are filtered out before pagination.
$this->drupalGet($node->toUrl('version-history'));
$assert = $this->assertSession();
$assert->pageTextContains('translation change 49');
$assert->elementsCount('css', '.node-revision-table tbody tr', 50);
$assert->elementNotExists('css', '.pager');
// Create another translation affecting revision.
$node->setTitle($this->randomString())
->setRevisionLogMessage('translation change 50');
$node->isDefaultRevision(FALSE);
$node->setNewRevision(TRUE);
$node->save();
// There should now be a pager, and the current revision should be on the
// second page.
$this->drupalGet($node->toUrl('version-history'));
$assert->elementExists('css', '.pager');
$assert->elementNotExists('css', '.revision-current');
$this->clickLink('Page 2');
$assert->elementsCount('css', '.node-revision-table tbody tr', 1);
$assert->elementExists('css', '.revision-current');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.