You are here

public function PagerTest::testPagerEllipsis in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Pager/PagerTest.php \Drupal\system\Tests\Pager\PagerTest::testPagerEllipsis()

Test proper functioning of the ellipsis.

File

core/modules/system/src/Tests/Pager/PagerTest.php, line 101
Contains \Drupal\system\Tests\Pager\PagerTest.

Class

PagerTest
Tests pager functionality.

Namespace

Drupal\system\Tests\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
    ->assertEqual(count($elements), 0, '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
    ->assertEqual(count($elements), 1, 'Found the ellipsis.');
}