function PagerTest::testActiveClass
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Pager/PagerTest.php \Drupal\Tests\system\Functional\Pager\PagerTest::testActiveClass()
- 10 core/modules/system/tests/src/Functional/Pager/PagerTest.php \Drupal\Tests\system\Functional\Pager\PagerTest::testActiveClass()
- 11.x core/modules/system/tests/src/Functional/Pager/PagerTest.php \Drupal\Tests\system\Functional\Pager\PagerTest::testActiveClass()
Tests markup and CSS classes of pager links.
File
-
core/
modules/ system/ tests/ src/ Functional/ Pager/ PagerTest.php, line 58
Class
- PagerTest
- Tests pager functionality.
Namespace
Drupal\Tests\system\Functional\PagerCode
public 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', [
'query' => [
'page' => $current_page,
],
]);
$this->assertPagerItems($current_page);
// Verify last page.
$elements = $this->xpath('//li[contains(@class, :class)]/a', [
':class' => 'pager__item--last',
]);
preg_match('@page=(\\d+)@', $elements[0]->getAttribute('href'), $matches);
$current_page = (int) $matches[1];
$this->drupalGet($GLOBALS['base_root'] . parse_url($this->getUrl())['path'] . $elements[0]->getAttribute('href'), [
'external' => TRUE,
]);
$this->assertPagerItems($current_page);
// Verify the pager does not render on a list without pagination.
$this->drupalGet('admin/config/media/image-styles');
$this->assertSession()
->elementNotExists('css', '.pager');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.