You are here

public function PagerTest::testPagerEllipsis in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Pager/PagerTest.php \Drupal\Tests\system\Functional\Pager\PagerTest::testPagerEllipsis()
  2. 9 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 194

Class

PagerTest
Tests pager functionality.

Namespace

Drupal\Tests\system\Functional\Pager

Code

public function testPagerEllipsis() {

  // 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.');
}