You are here

public function DisableUser1EditIntegrationTest::testDisableToggle in Disable user 1 edit 8

Tests if module works as expected before and after we toggle the disable.

File

tests/src/FunctionalJavascript/DisableUser1EditIntegrationTest.php, line 25

Class

DisableUser1EditIntegrationTest
Tests the admin functionality of the module.

Namespace

Drupal\Tests\disable_user_1_edit\FunctionalJavascript

Code

public function testDisableToggle() {
  $admin_user = $this
    ->drupalCreateUser([
    'administer users',
    'administer disable user 1 edit',
  ]);
  $this
    ->drupalLogin($admin_user);
  $this
    ->drupalGet('/user/1/edit');
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->drupalGet('/admin/config/people/disable_user_1_edit');

  // Test that it is possible to toggle it off, and that this has the desired
  // effect.
  $page = $this
    ->getSession()
    ->getPage();
  $page
    ->fillField('disabled', TRUE);
  $page
    ->pressButton('op');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
}