public function BasicAuthTest::testControllerNotCalledBeforeAuth in Drupal 9
Same name and namespace in other branches
- 8 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 251
Class
- BasicAuthTest
- Tests for BasicAuth authentication provider.
Namespace
Drupal\Tests\basic_auth\FunctionalCode
public function testControllerNotCalledBeforeAuth() {
$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');
}