function BasicAuthTest::testControllerNotCalledBeforeAuth

Same name in other branches
  1. 9 core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php \Drupal\Tests\basic_auth\Functional\BasicAuthTest::testControllerNotCalledBeforeAuth()
  2. 8.9.x core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php \Drupal\Tests\basic_auth\Functional\BasicAuthTest::testControllerNotCalledBeforeAuth()
  3. 10 core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php \Drupal\Tests\basic_auth\Functional\BasicAuthTest::testControllerNotCalledBeforeAuth()

Tests if the controller is called before authentication.

See also

https://www.drupal.org/node/2817727

File

core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php, line 252

Class

BasicAuthTest
Tests for BasicAuth authentication provider.

Namespace

Drupal\Tests\basic_auth\Functional

Code

public function testControllerNotCalledBeforeAuth() : void {
    $this->drupalGet('/basic_auth_test/state/modify');
    $this->assertSession()
        ->statusCodeEquals(401);
    $this->drupalGet('/basic_auth_test/state/read');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->pageTextContains('nope');
    $account = $this->drupalCreateUser();
    $this->basicAuthGet('/basic_auth_test/state/modify', $account->getAccountName(), $account->pass_raw);
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->pageTextContains('Done');
    $this->mink
        ->resetSessions();
    $this->drupalGet('/basic_auth_test/state/read');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->pageTextContains('yep');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.