protected function PagerTest::testPagerQueryParametersAndCacheContext in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Pager/PagerTest.php \Drupal\system\Tests\Pager\PagerTest::testPagerQueryParametersAndCacheContext()
Test proper functioning of the query parameters and the pager cache context.
File
- core/
modules/ system/ src/ Tests/ Pager/ PagerTest.php, line 75 - Contains \Drupal\system\Tests\Pager\PagerTest.
Class
- PagerTest
- Tests pager functionality.
Namespace
Drupal\system\Tests\PagerCode
protected function testPagerQueryParametersAndCacheContext() {
// First page.
$this
->drupalGet('pager-test/query-parameters');
$this
->assertText(t('Pager calls: 0'), 'Initial call to pager shows 0 calls.');
$this
->assertText('[url.query_args.pagers:0]=0.0');
$this
->assertCacheContext('url.query_args');
// Go to last page, the count of pager calls need to go to 1.
$elements = $this
->xpath('//li[contains(@class, :class)]/a', array(
':class' => 'pager__item--last',
));
$this
->drupalGet($this
->getAbsoluteUrl($elements[0]['href']));
$this
->assertText(t('Pager calls: 1'), 'First link call to pager shows 1 calls.');
$this
->assertText('[url.query_args.pagers:0]=0.60');
$this
->assertCacheContext('url.query_args');
// Go back to first page, the count of pager calls need to go to 2.
$elements = $this
->xpath('//li[contains(@class, :class)]/a', array(
':class' => 'pager__item--first',
));
$this
->drupalGet($this
->getAbsoluteUrl($elements[0]['href']));
$this
->drupalGet($GLOBALS['base_root'] . parse_url($this
->getUrl())['path'] . $elements[0]['href'], array(
'external' => TRUE,
));
$this
->assertText(t('Pager calls: 2'), 'Second link call to pager shows 2 calls.');
$this
->assertText('[url.query_args.pagers:0]=0.0');
$this
->assertCacheContext('url.query_args');
}