Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
Signed-off-by: nabim777 <[email protected]>
  • Loading branch information
nabim777 committed Feb 17, 2025
1 parent b3a31ad commit c8d6120
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tests/lib/Service/OpenProjectAPIServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4334,7 +4334,7 @@ public function dataProviderForIsUserOIDCAppSupported(): array {
'\OCA\UserOIDC\Exception\TokenExchangeFailedException',
'\OCA\UserOIDC\User\Backend',
],
false
true
],
[
true,
Expand All @@ -4349,7 +4349,7 @@ public function dataProviderForIsUserOIDCAppSupported(): array {
],
[
true,
'6.1.0', // user_oidc app Not supported version
'6.1.0', // Not supported user_oidc app version
[
'\OCA\UserOIDC\Db\ProviderMapper',
'\OCA\UserOIDC\Event\ExchangedTokenRequestedEvent',
Expand Down Expand Up @@ -4383,11 +4383,18 @@ public function testIsUserOIDCAppSupported(
): void {
$iAppManagerMock = $this->getMockBuilder(IAppManager::class)->getMock();
$iAppManagerMock->method('getAppVersion')->with('user_oidc')->willReturn($version);
$serviceMock = $this->getMockBuilder(OpenProjectAPIService::class)
->disableOriginalConstructor()
->getMock();
$serviceMock->method('isUserOIDCAppInstalledAndEnabled')->willReturn($installedAndEnabled);
$actualResult = $serviceMock->isUserOIDCAppSupported();
if (count($classesExist) === 4 && array_product(array_map('class_exists', $classesExist))) {
$service = $this->getOpenProjectAPIServiceMock(
['isUserOIDCAppInstalledAndEnabled'],
[
'appManager' => $iAppManagerMock,
],
);
$service->method('isUserOIDCAppInstalledAndEnabled')->willReturn($installedAndEnabled);
$actualResult = $service->isUserOIDCAppSupported();
} else {
$actualResult = false;
}
$this->assertEquals($expected, $actualResult);
}
}

0 comments on commit c8d6120

Please sign in to comment.