ModulesListFormWebTest.php 1.55 KB
Newer Older
1
2
<?php

3
namespace Drupal\Tests\system\Functional\Form;
4

5
use Drupal\Tests\BrowserTestBase;
6
7
8

/**
 * Tests \Drupal\system\Form\ModulesListForm.
9
10
 *
 * @group Form
11
 */
12
class ModulesListFormWebTest extends BrowserTestBase {
13
14
15
16

  /**
   * {@inheritdoc}
   */
17
  public static $modules = ['system_test', 'help'];
18
19
20
21

  /**
   * {@inheritdoc}
   */
22
  protected function setUp() {
23
24
25
26
27
28
29
30
    parent::setUp();
    \Drupal::state()->set('system_test.module_hidden', FALSE);
  }

  /**
   * Tests the module list form.
   */
  public function testModuleListForm() {
31
32
    $this->drupalLogin(
      $this->drupalCreateUser(
33
        ['administer modules', 'administer permissions']
34
35
      )
    );
36
37
38
39
    $this->drupalGet('admin/modules');
    $this->assertResponse('200');

    // Check that system_test's configure link was rendered correctly.
40
    $this->assertFieldByXPath("//a[contains(@href, '/system-test/configure/bar') and text()='Configure ']/span[contains(@class, 'visually-hidden') and text()='the System test module']");
41
42
43

    // Check that system_test's permissions link was rendered correctly.
    $this->assertFieldByXPath("//a[contains(@href, '/admin/people/permissions#module-system_test') and @title='Configure permissions']");
44
45
46

    // Check that system_test's help link was rendered correctly.
    $this->assertFieldByXPath("//a[contains(@href, '/admin/help/system_test') and @title='Help']");
47
48
49
50
51

    // Ensure that the Testing module's machine name is printed. Testing module
    // is used because its machine name is different than its human readable
    // name.
    $this->assertText('simpletest');
52
  }
53

54
}