function ConfigEntityListTest::testPager
Same name in other branches
- 9 core/modules/config/tests/src/Functional/ConfigEntityListTest.php \Drupal\Tests\config\Functional\ConfigEntityListTest::testPager()
- 8.9.x core/modules/config/tests/src/Functional/ConfigEntityListTest.php \Drupal\Tests\config\Functional\ConfigEntityListTest::testPager()
- 11.x core/modules/config/tests/src/Functional/ConfigEntityListTest.php \Drupal\Tests\config\Functional\ConfigEntityListTest::testPager()
Tests paging.
File
-
core/
modules/ config/ tests/ src/ Functional/ ConfigEntityListTest.php, line 315
Class
- ConfigEntityListTest
- Tests the listing of configuration entities.
Namespace
Drupal\Tests\config\FunctionalCode
public function testPager() : void {
$this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
]));
$storage = \Drupal::service('entity_type.manager')->getListBuilder('config_test')
->getStorage();
// Create 51 test entities.
for ($i = 1; $i < 52; $i++) {
$storage->create([
'id' => str_pad((string) $i, 2, '0', STR_PAD_LEFT),
'label' => 'Test config entity ' . $i,
'weight' => $i,
'protected_property' => $i,
])
->save();
}
// Load the listing page.
$this->drupalGet('admin/structure/config_test');
// Item 51 should not be present.
$this->assertSession()
->pageTextContains('Test config entity 50');
$this->assertSession()
->responseNotContains('Test config entity 51');
// Browse to the next page, test config entity 51 is on page 2.
$this->clickLink('Page 2');
$this->assertSession()
->responseNotContains('Test config entity 50');
$this->assertSession()
->responseContains('dotted.default');
$this->assertSession()
->pageTextContains('Test config entity 51');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.