You are here

function PagerFunctionalWebTestCase::testActiveClass in Drupal 7

Tests markup and CSS classes of pager links.

File

modules/simpletest/tests/pager.test, line 39
Tests for pager functionality.

Class

PagerFunctionalWebTestCase
Tests pager functionality.

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);
}