function EntityListBuilderTest::testPager

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php \Drupal\Tests\system\Functional\Entity\EntityListBuilderTest::testPager()
  2. 8.9.x core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php \Drupal\Tests\system\Functional\Entity\EntityListBuilderTest::testPager()
  3. 10 core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php \Drupal\Tests\system\Functional\Entity\EntityListBuilderTest::testPager()

Tests paging.

File

core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php, line 43

Class

EntityListBuilderTest
Tests entity list builder functionality.

Namespace

Drupal\Tests\system\Functional\Entity

Code

public function testPager() : void {
    // Create 51 test entities.
    for ($i = 1; $i < 52; $i++) {
        EntityTest::create([
            'name' => 'Test entity ' . $i,
        ])->save();
    }
    // Load the listing page.
    $this->drupalGet('entity_test/list');
    // Item 51 should not be present.
    $this->assertSession()
        ->pageTextContains('Test entity 50');
    $this->assertSession()
        ->responseNotContains('Test entity 51');
    // Browse to the next page, test entity 51 is shown.
    $this->clickLink('Page 2');
    $this->assertSession()
        ->responseNotContains('Test entity 50');
    $this->assertSession()
        ->pageTextContains('Test entity 51');
}

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