public function OpenIDConnectTest::testHasSetPasswordAccess in OpenID Connect / OAuth client 2.x
Same name and namespace in other branches
- 8 tests/src/Unit/OpenIDConnectTest.php \Drupal\Tests\openid_connect\Unit\OpenIDConnectTest::testHasSetPasswordAccess()
Test for the hasSetPassword method.
@dataProvider dataProviderForHasSetPasswordAccess
Parameters
\Drupal\Tests\openid_connect\Unit\MockObject|null $account: The account to test or null if none provided.
bool $hasPermission: Whether the account should have the correct permission to change their own password.
array $connectedAccounts: The connected accounts array from the authMap method.
bool $expectedResult: The result expected.
File
- tests/
src/ Unit/ OpenIDConnectTest.php, line 308
Class
- OpenIDConnectTest
- Provides tests for the OpenID Connect module.
Namespace
Drupal\Tests\openid_connect\UnitCode
public function testHasSetPasswordAccess(?MockObject $account, bool $hasPermission, array $connectedAccounts, bool $expectedResult) : void {
if (empty($account)) {
$this->currentUser
->expects($this
->once())
->method('hasPermission')
->with('openid connect set own password')
->willReturn($hasPermission);
if (!$hasPermission) {
$this->authmap
->expects($this
->once())
->method('getAll')
->willReturn($connectedAccounts);
}
}
else {
$account
->expects($this
->once())
->method('hasPermission')
->with('openid connect set own password')
->willReturn($hasPermission);
if (!$hasPermission) {
$this->authmap
->expects($this
->once())
->method('getAll')
->willReturn($connectedAccounts);
}
}
$actualResult = $this->openIdConnect
->hasSetPasswordAccess($account);
$this
->assertEquals($expectedResult, $actualResult);
}