ConfigDraggableListBuilderTest.php 1.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<?php

namespace Drupal\Tests\config\Functional;

use Drupal\Tests\BrowserTestBase;
use Drupal\user\Entity\Role;

/**
 * Tests draggable list builder.
 *
 * @group config
 */
class ConfigDraggableListBuilderTest extends BrowserTestBase {

  /**
   * {@inheritdoc}
   */
18
  protected static $modules = ['config_test'];
19

20 21 22 23 24
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

25 26 27 28
  /**
   * Test draggable lists.
   */
  public function testDraggableList() {
29
    $this->drupalLogin($this->drupalCreateUser(['administer permissions']));
30 31 32 33 34 35 36 37 38 39 40 41 42 43

    // 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.
44
    $this->assertSession()->titleEquals('Roles | Drupal');
45 46 47 48 49 50 51 52 53 54

    // 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");
    }
  }

}