function PagerTest::testActiveClass

Tests markup and CSS classes of pager links.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php, line 52
Definition of Drupal\system\Tests\Pager\PagerTest.

Class

PagerTest
Tests pager functionality.

Namespace

Drupal\system\Tests\Pager

Code

function testActiveClass() {

  // Verify first page.
  $this
    ->drupalGet('admin/reports/dblog');
  $current_page = 0;
  $this
    ->assertPagerItems($current_page);

  // Verify any page but first/last.
  $current_page++;
  $this
    ->drupalGet('admin/reports/dblog', array(
    'query' => array(
      'page' => $current_page,
    ),
  ));
  $this
    ->assertPagerItems($current_page);

  // Verify last page.
  $elements = $this
    ->xpath('//li[contains(@class, :class)]/a', array(
    ':class' => 'pager-last',
  ));
  preg_match('@page=(\\d+)@', $elements[0]['href'], $matches);
  $current_page = (int) $matches[1];
  $this
    ->drupalGet($GLOBALS['base_root'] . $elements[0]['href'], array(
    'external' => TRUE,
  ));
  $this
    ->assertPagerItems($current_page);
}