function PagerTest::testPagerEllipsis

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Pager/PagerTest.php \Drupal\Tests\system\Functional\Pager\PagerTest::testPagerEllipsis()
  2. 8.9.x core/modules/system/tests/src/Functional/Pager/PagerTest.php \Drupal\Tests\system\Functional\Pager\PagerTest::testPagerEllipsis()
  3. 11.x core/modules/system/tests/src/Functional/Pager/PagerTest.php \Drupal\Tests\system\Functional\Pager\PagerTest::testPagerEllipsis()

Tests proper functioning of the ellipsis.

File

core/modules/system/tests/src/Functional/Pager/PagerTest.php, line 196

Class

PagerTest
Tests pager functionality.

Namespace

Drupal\Tests\system\Functional\Pager

Code

public function testPagerEllipsis() : void {
  // Insert 100 extra log messages to get 9 pages.
  $logger = $this->container
    ->get('logger.factory')
    ->get('pager_test');
  for ($i = 0; $i < 100; $i++) {
    $logger->debug($this->randomString());
  }
  $this->drupalGet('admin/reports/dblog');
  $elements = $this->cssSelect(".pager__item--ellipsis:contains('…')");
  $this->assertCount(0, $elements, 'No ellipsis has been set.');
  // Insert an extra 50 log messages to get 10 pages.
  $logger = $this->container
    ->get('logger.factory')
    ->get('pager_test');
  for ($i = 0; $i < 50; $i++) {
    $logger->debug($this->randomString());
  }
  $this->drupalGet('admin/reports/dblog');
  $elements = $this->cssSelect(".pager__item--ellipsis:contains('…')");
  $this->assertCount(1, $elements, 'Found the ellipsis.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.