function ConfigDraggableListBuilderTest::testDraggableList

Same name and namespace in other branches
  1. 9 core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php \Drupal\Tests\config\Functional\ConfigDraggableListBuilderTest::testDraggableList()
  2. 10 core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php \Drupal\Tests\config\Functional\ConfigDraggableListBuilderTest::testDraggableList()
  3. 11.x core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php \Drupal\Tests\config\Functional\ConfigDraggableListBuilderTest::testDraggableList()

Test draggable lists.

File

core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php, line 28

Class

ConfigDraggableListBuilderTest
Tests draggable list builder.

Namespace

Drupal\Tests\config\Functional

Code

public function testDraggableList() {
  $this->drupalLogin($this->drupalCreateUser([
    'administer permissions',
  ]));
  // Create more than 50 roles.
  for ($i = 0; $i < 51; $i++) {
    $role = Role::create([
      'id' => 'role_' . $i,
      'label' => "Role {$i}",
    ]);
    $role->save();
  }
  // Navigate to Roles page
  $this->drupalGet('admin/people/roles');
  // Test for the page title.
  $this->assertSession()
    ->titleEquals('Roles | Drupal');
  // Count the number of rows in table.
  $rows = $this->xpath('//form[@class="user-admin-roles-form"]/table/tbody/tr');
  $this->assertGreaterThan(50, count($rows));
  for ($i = 0; $i < 51; $i++) {
    $this->assertSession()
      ->pageTextContains("Role {$i}");
  }
}

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