You are here

public function DiffRevisionTest::testOverviewPager in Diff 8

Tests pager on diff overview.

File

tests/src/Functional/DiffRevisionTest.php, line 291

Class

DiffRevisionTest
Tests the diff revisions overview.

Namespace

Drupal\Tests\diff\Functional

Code

public function testOverviewPager() {
  $this
    ->config('diff.settings')
    ->set('general_settings.revision_pager_limit', 10)
    ->save();
  $this
    ->loginAsAdmin([
    'view article revisions',
  ]);
  $node = $this
    ->drupalCreateNode([
    'type' => 'article',
  ]);

  // Create 11 more revisions in order to trigger paging on the revisions
  // overview screen.
  for ($i = 0; $i < 11; $i++) {
    $edit = [
      'revision' => TRUE,
      'body[0][value]' => 'change: ' . $i,
    ];
    $this
      ->drupalPostNodeForm('node/' . $node
      ->id() . '/edit', $edit, t('Save and keep published'));
  }

  // Check the number of elements on the first page.
  $this
    ->drupalGet('node/' . $node
    ->id() . '/revisions');
  $element = $this
    ->xpath('//*[@id="edit-node-revisions-table"]/tbody/tr');
  $this
    ->assertEqual(count($element), 10);

  // Check that the pager exists.
  $this
    ->assertRaw('page=1');
  $this
    ->clickLink('Next page');

  // Check the number of elements on the second page.
  $element = $this
    ->xpath('//*[@id="edit-node-revisions-table"]/tbody/tr');
  $this
    ->assertEqual(count($element), 2);
  $this
    ->assertRaw('page=0');
  $this
    ->clickLink('Previous page');
}