function OliveroTest::testPagerAttribute
Same name in other branches
- 10 core/tests/Drupal/FunctionalTests/Theme/OliveroTest.php \Drupal\FunctionalTests\Theme\OliveroTest::testPagerAttribute()
Tests pager attribute is present using pager_test.
File
-
core/
tests/ Drupal/ FunctionalTests/ Theme/ OliveroTest.php, line 139
Class
- OliveroTest
- Tests the Olivero theme.
Namespace
Drupal\FunctionalTests\ThemeCode
public function testPagerAttribute() : void {
// Insert 300 log messages.
$logger = \Drupal::logger('pager_test');
for ($i = 0; $i < 300; $i++) {
$logger->debug($this->randomString());
}
$this->drupalLogin($this->drupalCreateUser([
'access site reports',
]));
$this->drupalGet('pager-test/multiple-pagers', [
'query' => [
'page' => 1,
],
]);
$this->assertSession()
->statusCodeEquals(200);
$elements = $this->xpath('//ul[contains(@class, :class)]/li', [
':class' => 'pager__items',
]);
$this->assertNotEmpty($elements, 'Pager found.');
// Check all links for pager-test attribute.
foreach ($elements as $element) {
$link = $element->find('css', 'a');
// Current page does not have a link.
if (empty($link)) {
continue;
}
$this->assertTrue($link->hasAttribute('pager-test'), 'Pager item has attribute pager-test');
$this->assertTrue($link->hasClass('lizards'));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.