69 lines
3.2 KiB
PHP
69 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace MintyPHP\Tests\Service\Auth;
|
|
|
|
use MintyPHP\Service\Auth\ApiTokenService;
|
|
use MintyPHP\Service\Auth\AuthService;
|
|
use MintyPHP\Service\Auth\AuthServicesFactory;
|
|
use MintyPHP\Service\Auth\EmailVerificationService;
|
|
use MintyPHP\Service\Auth\MicrosoftOidcService;
|
|
use MintyPHP\Service\Auth\MicrosoftOidcStateStoreService;
|
|
use MintyPHP\Service\Auth\PasswordResetService;
|
|
use MintyPHP\Service\Auth\RememberMeService;
|
|
use MintyPHP\Service\Auth\SsoUserLinkService;
|
|
use MintyPHP\Service\Auth\TenantSsoService;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class AuthServicesFactoryTest extends TestCase
|
|
{
|
|
public function testFactoryReturnsStableInstancesPerFactoryObject(): void
|
|
{
|
|
$factory = new AuthServicesFactory();
|
|
|
|
$apiTokenServiceA = $factory->createApiTokenService();
|
|
$apiTokenServiceB = $factory->createApiTokenService();
|
|
$this->assertInstanceOf(ApiTokenService::class, $apiTokenServiceA);
|
|
$this->assertSame($apiTokenServiceA, $apiTokenServiceB);
|
|
|
|
$passwordResetServiceA = $factory->createPasswordResetService();
|
|
$passwordResetServiceB = $factory->createPasswordResetService();
|
|
$this->assertInstanceOf(PasswordResetService::class, $passwordResetServiceA);
|
|
$this->assertSame($passwordResetServiceA, $passwordResetServiceB);
|
|
|
|
$emailVerificationServiceA = $factory->createEmailVerificationService();
|
|
$emailVerificationServiceB = $factory->createEmailVerificationService();
|
|
$this->assertInstanceOf(EmailVerificationService::class, $emailVerificationServiceA);
|
|
$this->assertSame($emailVerificationServiceA, $emailVerificationServiceB);
|
|
|
|
$rememberMeServiceA = $factory->createRememberMeService();
|
|
$rememberMeServiceB = $factory->createRememberMeService();
|
|
$this->assertInstanceOf(RememberMeService::class, $rememberMeServiceA);
|
|
$this->assertSame($rememberMeServiceA, $rememberMeServiceB);
|
|
|
|
$authServiceA = $factory->createAuthService();
|
|
$authServiceB = $factory->createAuthService();
|
|
$this->assertInstanceOf(AuthService::class, $authServiceA);
|
|
$this->assertSame($authServiceA, $authServiceB);
|
|
|
|
$ssoUserLinkServiceA = $factory->createSsoUserLinkService();
|
|
$ssoUserLinkServiceB = $factory->createSsoUserLinkService();
|
|
$this->assertInstanceOf(SsoUserLinkService::class, $ssoUserLinkServiceA);
|
|
$this->assertSame($ssoUserLinkServiceA, $ssoUserLinkServiceB);
|
|
|
|
$tenantSsoServiceA = $factory->createTenantSsoService();
|
|
$tenantSsoServiceB = $factory->createTenantSsoService();
|
|
$this->assertInstanceOf(TenantSsoService::class, $tenantSsoServiceA);
|
|
$this->assertSame($tenantSsoServiceA, $tenantSsoServiceB);
|
|
|
|
$stateStoreA = $factory->createMicrosoftOidcStateStore();
|
|
$stateStoreB = $factory->createMicrosoftOidcStateStore();
|
|
$this->assertInstanceOf(MicrosoftOidcStateStoreService::class, $stateStoreA);
|
|
$this->assertSame($stateStoreA, $stateStoreB);
|
|
|
|
$microsoftOidcServiceA = $factory->createMicrosoftOidcService();
|
|
$microsoftOidcServiceB = $factory->createMicrosoftOidcService();
|
|
$this->assertInstanceOf(MicrosoftOidcService::class, $microsoftOidcServiceA);
|
|
$this->assertSame($microsoftOidcServiceA, $microsoftOidcServiceB);
|
|
}
|
|
}
|