function PagerTest::testPager
Same name in other branches
- 9 core/modules/views/tests/src/Functional/Wizard/PagerTest.php \Drupal\Tests\views\Functional\Wizard\PagerTest::testPager()
- 10 core/modules/views/tests/src/Functional/Wizard/PagerTest.php \Drupal\Tests\views\Functional\Wizard\PagerTest::testPager()
- 11.x core/modules/views/tests/src/Functional/Wizard/PagerTest.php \Drupal\Tests\views\Functional\Wizard\PagerTest::testPager()
Tests the pager option.
File
-
core/
modules/ views/ tests/ src/ Functional/ Wizard/ PagerTest.php, line 20
Class
- PagerTest
- Tests the ability of the views wizard to create views without a pager.
Namespace
Drupal\Tests\views\Functional\WizardCode
public function testPager() {
// Create nodes, each with a different creation time so that we have
// conditions that are meaningful for the use of a pager.
$this->drupalCreateContentType([
'type' => 'page',
]);
for ($i = 0; $i < 12; $i++) {
$this->drupalCreateNode([
'created' => REQUEST_TIME - $i,
]);
}
// Make a View that uses a pager.
$path_with_pager = 'test-view-with-pager';
$this->createViewAtPath($path_with_pager, TRUE);
$this->drupalGet($path_with_pager);
// This technique for finding the existence of a pager
// matches that used in Drupal\views_ui\Tests\PreviewTest.php.
$elements = $this->xpath('//ul[contains(@class, :class)]/li', [
':class' => 'pager__items',
]);
$this->assertTrue(!empty($elements), 'Full pager found.');
// Make a View that does not have a pager.
$path_with_no_pager = 'test-view-without-pager';
$this->createViewAtPath($path_with_no_pager, FALSE);
$this->drupalGet($path_with_no_pager);
$elements = $this->xpath('//ul[contains(@class, :class)]/li', [
':class' => 'pager__items',
]);
$this->assertTrue(empty($elements), 'Full pager not found.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.