Version 1
[yaffs-website] / web / core / modules / config / tests / src / Functional / ConfigDraggableListBuilderTest.php
1 <?php
2
3 namespace Drupal\Tests\config\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6 use Drupal\user\Entity\Role;
7
8 /**
9  * Tests draggable list builder.
10  *
11  * @group config
12  */
13 class ConfigDraggableListBuilderTest extends BrowserTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['config_test'];
19
20   /**
21    * Test draggable lists.
22    */
23   public function testDraggableList() {
24     $this->drupalLogin($this->drupalCreateUser(['administer permissions']));
25
26     // Create more than 50 roles.
27     for ($i = 0; $i < 51; $i++) {
28       $role = Role::create([
29         'id' => 'role_' . $i,
30         'label' => "Role $i",
31       ]);
32       $role->save();
33     }
34
35     // Navigate to Roles page
36     $this->drupalGet('admin/people/roles');
37
38     // Test for the page title.
39     $this->assertSession()->titleEquals(t('Roles') . ' | Drupal');
40
41     // Count the number of rows in table.
42     $rows = $this->xpath('//form[@class="user-admin-roles-form"]/table/tbody/tr');
43     $this->assertGreaterThan(50, count($rows));
44     for ($i = 0; $i < 51; $i++) {
45       $this->assertSession()->pageTextContains("Role $i");
46     }
47   }
48
49 }