You are here

public function CasUserManagerTest::testUserRegister 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::testUserRegister()

Basic scenario that user is registered.

Create new account for a user.

@covers ::register

File

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

Class

CasUserManagerTest
CasUserManager unit tests.

Namespace

Drupal\Tests\cas\Unit\Service

Code

public function testUserRegister() {
  $config_factory = $this
    ->getConfigFactoryStub([
    'cas.settings' => [
      'user_accounts.auto_assigned_roles' => [],
    ],
  ]);
  $this->externalAuth
    ->method('register')
    ->willReturn($this->account);
  $cas_user_manager = $this
    ->getMockBuilder('Drupal\\cas\\Service\\CasUserManager')
    ->setMethods([
    'randomPassword',
  ])
    ->setConstructorArgs([
    $this->externalAuth,
    $this->authmap,
    $config_factory,
    $this->session,
    $this->connection,
    $this->eventDispatcher,
    $this->casHelper,
    $this->casProxyHelper
      ->reveal(),
  ])
    ->getMock();
  $this
    ->assertNotEmpty($cas_user_manager
    ->register('test', [], 'test'), 'Successfully registered user.');
}