public function CasEventsTest::testRegistrationCancelling in CAS 2.x
Tests cancelling the login with auto register process from a subscriber.
File
- tests/
src/ Functional/ CasEventsTest.php, line 78
Class
- CasEventsTest
- Tests CAS events.
Namespace
Drupal\Tests\cas\FunctionalCode
public function testRegistrationCancelling() : void {
// Get auto register from cas settings.
$settings = $this
->config('cas.settings');
$settings
->set('user_accounts.auto_register', TRUE)
->save();
// Add a CAS user.
$this
->createCasUser('Antoine Batiste', 'antoine@example.com', 'baTistE', []);
// Place the login/logout block so that we can check if user is logged in.
$this
->placeBlock('system_menu_block:account');
// Check the case when the subscriber didn't set a reason message.
\Drupal::state()
->set('cas_test.flag', 'cancel register without message');
$this
->casLogin('antoine@example.com', 'baTistE');
$this
->assertSession()
->pageTextContains('You do not have access to log in to this website. Please contact a site administrator if you believe you should have access.');
$this
->assertSession()
->linkExists('Log in');
// Check the case when the subscriber has set a reason message.
\Drupal::state()
->set('cas_test.flag', 'cancel register with message');
$this
->casLogin('antoine@example.com', 'baTistE');
$this
->assertSession()
->pageTextContains('Cancelled with a custom message.');
$this
->assertSession()
->linkExists('Log in');
}