You are here

function PagerTest::testActiveClass in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Pager/PagerTest.php \Drupal\system\Tests\Pager\PagerTest::testActiveClass()

Tests markup and CSS classes of pager links.

File

core/modules/system/src/Tests/Pager/PagerTest.php, line 53
Contains \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__item--last',
  ));
  preg_match('@page=(\\d+)@', $elements[0]['href'], $matches);
  $current_page = (int) $matches[1];
  $this
    ->drupalGet($GLOBALS['base_root'] . parse_url($this
    ->getUrl())['path'] . $elements[0]['href'], array(
    'external' => TRUE,
  ));
  $this
    ->assertPagerItems($current_page);
}