You are here

public function CasUserManagerTest::testBlockedAccountIsNotLoggedIn in CAS 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/Service/CasUserManagerTest.php \Drupal\Tests\cas\Unit\Service\CasUserManagerTest::testBlockedAccountIsNotLoggedIn()

Blockers users cannot log in.

@covers ::login

File

tests/src/Unit/Service/CasUserManagerTest.php, line 450

Class

CasUserManagerTest
CasUserManager unit tests.

Namespace

Drupal\Tests\cas\Unit\Service

Code

public function testBlockedAccountIsNotLoggedIn() {
  $cas_user_manager = $this
    ->getMockBuilder('Drupal\\cas\\Service\\CasUserManager')
    ->setMethods([
    'storeLoginSessionData',
  ])
    ->setConstructorArgs([
    $this->externalAuth,
    $this->authmap,
    $this
      ->getConfigFactoryStub(),
    $this->session,
    $this->connection,
    $this->eventDispatcher,
    $this->casHelper,
    $this->casProxyHelper
      ->reveal(),
  ])
    ->getMock();
  $this->account
    ->method('isactive')
    ->willReturn(FALSE);
  $this->account
    ->method('getaccountname')
    ->willReturn('user');
  $this->externalAuth
    ->method('load')
    ->willReturn($this->account);
  $this->externalAuth
    ->expects($this
    ->never())
    ->method('userLoginFinalize');
  $this
    ->expectException('Drupal\\cas\\Exception\\CasLoginException', 'The username user has not been activated or is blocked.');
  $this->session
    ->method('set')
    ->withConsecutive([
    'is_cas_user',
    TRUE,
  ], [
    'cas_username',
    'test',
  ]);
  $propertyBag = new CasPropertyBag('test');
  $cas_user_manager
    ->login($propertyBag, 'ticket');
}