You are here

public function RedirectOnLoginTest::testSettingsForm in Moderation Dashboard 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Functional/RedirectOnLoginTest.php \Drupal\Tests\moderation_dashboard\Functional\RedirectOnLoginTest::testSettingsForm()

Tests if settings form is working as expected.

File

tests/src/Functional/RedirectOnLoginTest.php, line 41

Class

RedirectOnLoginTest
Tests redirect on login configuration.

Namespace

Drupal\Tests\moderation_dashboard\Functional

Code

public function testSettingsForm() {
  $admin = $this
    ->createUser([], NULL, TRUE);
  $assert_session = $this
    ->assertSession();
  $this
    ->drupalLogin($admin);
  $this
    ->drupalGet('admin/config/people/moderation_dashboard');

  // Disabling redirect on login.
  $this
    ->submitForm([
    'redirect_on_login' => FALSE,
  ], 'Save configuration');
  $status_message = $assert_session
    ->elementExists('css', 'div[role="contentinfo"]')
    ->getText();
  $this
    ->assertSame('Status message The configuration options have been saved.', $status_message);
  $this
    ->assertSame(FALSE, $this
    ->config('moderation_dashboard.settings')
    ->get('redirect_on_login'));

  // Enabling redirect on login.
  $this
    ->submitForm([
    'redirect_on_login' => TRUE,
  ], 'Save configuration');
  $status_message = $assert_session
    ->elementExists('css', 'div[role="contentinfo"]')
    ->getText();
  $this
    ->assertSame('Status message The configuration options have been saved.', $status_message);
  $this
    ->assertSame(TRUE, $this
    ->config('moderation_dashboard.settings')
    ->get('redirect_on_login'));
}