You are here

public function ModerationDashboardRedirectTest::testNoRedirect in Moderation Dashboard 2.0.x

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

Tests if login is not redirected when the user requested another page.

Throws

\Behat\Mink\Exception\ExpectationException

File

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

Class

ModerationDashboardRedirectTest
Tests redirection to dashboard on login.

Namespace

Drupal\Tests\moderation_dashboard\Functional

Code

public function testNoRedirect() {

  // Anonymous user is redirected to login screen.
  // After successful login the requested page is shown.
  $this
    ->drupalGet('admin/content');
  $status_code = $this
    ->getSession()
    ->getStatusCode();
  $this
    ->assertEquals(403, $status_code);
  $this
    ->config('moderation_dashboard.settings')
    ->set('redirect_on_login', FALSE)
    ->save();
  $this
    ->drupalGet('user/login');
  $this
    ->drupalLogin($this->user);
  $this
    ->assertSession()
    ->addressEquals("user/{$this->user->id()}");
}