public function PagerTest::testPagerQueryParametersAndCacheContext in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/Pager/PagerTest.php \Drupal\Tests\system\Functional\Pager\PagerTest::testPagerQueryParametersAndCacheContext()
- 9 core/modules/system/tests/src/Functional/Pager/PagerTest.php \Drupal\Tests\system\Functional\Pager\PagerTest::testPagerQueryParametersAndCacheContext()
Tests proper functioning of the query parameters and the pager cache context.
File
- core/
modules/ system/ tests/ src/ Functional/ Pager/ PagerTest.php, line 85
Class
- PagerTest
- Tests pager functionality.
Namespace
Drupal\Tests\system\Functional\PagerCode
public function testPagerQueryParametersAndCacheContext() {
// First page.
$this
->drupalGet('pager-test/query-parameters');
$this
->assertSession()
->pageTextContains('Pager calls: 0');
$this
->assertSession()
->pageTextContains('[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.
$this
->assertSession()
->elementExists('xpath', '//li[contains(@class, "pager__item--last")]/a')
->click();
$this
->assertSession()
->pageTextContains('Pager calls: 1');
$this
->assertSession()
->pageTextContains('[url.query_args.pagers:0]=0.60');
$this
->assertCacheContext('url.query_args');
// Reset counter to 0.
$this
->drupalGet('pager-test/query-parameters');
// Go back to first page, the count of pager calls need to go to 2.
$this
->assertSession()
->elementExists('xpath', '//li[contains(@class, "pager__item--last")]/a')
->click();
$this
->assertSession()
->elementExists('xpath', '//li[contains(@class, "pager__item--first")]/a')
->click();
$this
->assertSession()
->pageTextContains('Pager calls: 2');
$this
->assertSession()
->pageTextContains('[url.query_args.pagers:0]=0.0');
$this
->assertCacheContext('url.query_args');
}