RedirectOnLoginTest.php in Moderation Dashboard 8
File
tests/src/Functional/RedirectOnLoginTest.php
View source
<?php
namespace Drupal\Tests\moderation_dashboard\Functional;
class RedirectOnLoginTest extends ModerationDashboardTestBase {
public function testEnabled() {
$this
->assertSame(TRUE, $this
->config('moderation_dashboard.settings')
->get('redirect_on_login'));
$this
->drupalLogin($this->user);
$this
->assertSession()
->addressEquals("user/{$this->user->id()}/moderation/dashboard");
}
public function testDisabled() {
$this
->config('moderation_dashboard.settings')
->set('redirect_on_login', FALSE)
->save();
$this
->drupalLogin($this->user);
$this
->assertSession()
->addressEquals("user/{$this->user->id()}");
}
public function testSettingsForm() {
$admin = $this
->createUser([], NULL, TRUE);
$assert_session = $this
->assertSession();
$this
->drupalLogin($admin);
$this
->drupalGet('admin/config/people/moderation_dashboard');
$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'));
$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'));
}
}