You are here

public function RedirectOnLoginTest::testSettingsForm in Moderation Dashboard 2.0.x

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

Tests if settings form is working as expected.

Throws

\Drupal\Core\Entity\EntityStorageException

File

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

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'));
}