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. 10 core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php \Drupal\Tests\system\Functional\Entity\EntityListBuilderTest::testPager()
  3. 11.x core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php \Drupal\Tests\system\Functional\Entity\EntityListBuilderTest::testPager()

Test paging.

File

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

Class

EntityListBuilderTest
Tests entity list builder functionality.

Namespace

Drupal\Tests\system\Functional\Entity

Code

public function testPager() {
    // 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->assertRaw('Test entity 50', 'Item 50 is shown.');
    $this->assertNoRaw('Test entity 51', 'Item 51 is on the next page.');
    // Browse to the next page.
    $this->clickLink(t('Page 2'));
    $this->assertNoRaw('Test entity 50', 'Test entity 50 is on the previous page.');
    $this->assertRaw('Test entity 51', 'Test entity 51 is shown.');
}

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