You are here

public function ForcePasswordChangeFunctionalityTest::testDisableModuleInSettingsPhp in Force Password Change 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Functional/ForcePasswordChangeFunctionalityTest.php \Drupal\Tests\force_password_change\Functional\ForcePasswordChangeFunctionalityTest::testDisableModuleInSettingsPhp()

File

tests/src/Functional/ForcePasswordChangeFunctionalityTest.php, line 295

Class

ForcePasswordChangeFunctionalityTest
@group force_password_change

Namespace

Drupal\Tests\force_password_change\Functional

Code

public function testDisableModuleInSettingsPhp() {
  $admin_user = $this
    ->drupalCreateUser([
    'administer force password change',
    'access administration pages',
  ]);
  $this
    ->drupalLogin($admin_user);

  // Go to admin page
  $this
    ->drupalGet('admin/config/people/force_password_change');
  $this
    ->assertStatusCodeEquals(200);
  $this
    ->checkCheckbox('#edit-roles-authenticated');
  $this
    ->click('#edit-submit');

  // Check that redirect properly occurred
  $this
    ->assertSession()
    ->addressMatches('/\\/user\\/2\\/edit$/');
  $this
    ->assertSession()
    ->pageTextContains('An administrator has required that you change your password. Please change your password to proceed.');

  // Disable module in cofig
  \Drupal::service('config.factory')
    ->getEditable('force_password_change.settings')
    ->set('enabled', FALSE)
    ->save();

  // Go to admin page to ensure functionality is disabled
  $this
    ->drupalGet('admin/config/people/force_password_change');
  $this
    ->assertStatusCodeEquals(200);
}