test: add 92 tests for 12 untested gateway and service classes
Cover Settings gateways (Session, LoginPersistence, SystemAudit, Smtp, FrontendTelemetry, Metadata, App), Auth gateways (ExternalIdentity, Tenant), DirectorySettings, UserSettings, and HotkeyService. Gateway test coverage rises from 25% to 52%, overall service/gateway coverage from 58.6% to 70.7%. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
66
tests/Service/Auth/AuthTenantGatewayTest.php
Normal file
66
tests/Service/Auth/AuthTenantGatewayTest.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Tests\Service\Auth;
|
||||
|
||||
use MintyPHP\Repository\Tenant\TenantRepositoryInterface;
|
||||
use MintyPHP\Service\Auth\AuthTenantGateway;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AuthTenantGatewayTest extends TestCase
|
||||
{
|
||||
public function testFindByIdDelegatesToRepository(): void
|
||||
{
|
||||
$tenant = ['id' => 1, 'name' => 'Acme Corp', 'uuid' => 'abc-123'];
|
||||
|
||||
$repo = $this->createMock(TenantRepositoryInterface::class);
|
||||
$repo->expects($this->once())
|
||||
->method('find')
|
||||
->with(1)
|
||||
->willReturn($tenant);
|
||||
|
||||
$gateway = new AuthTenantGateway($repo);
|
||||
$this->assertSame($tenant, $gateway->findById(1));
|
||||
}
|
||||
|
||||
public function testFindByIdReturnsNullWhenNotFound(): void
|
||||
{
|
||||
$repo = $this->createMock(TenantRepositoryInterface::class);
|
||||
$repo->expects($this->once())
|
||||
->method('find')
|
||||
->with(999)
|
||||
->willReturn(null);
|
||||
|
||||
$gateway = new AuthTenantGateway($repo);
|
||||
$this->assertNull($gateway->findById(999));
|
||||
}
|
||||
|
||||
public function testFindByUuidDelegatesToRepository(): void
|
||||
{
|
||||
$tenant = ['id' => 5, 'name' => 'Beta Inc', 'uuid' => 'def-456'];
|
||||
|
||||
$repo = $this->createMock(TenantRepositoryInterface::class);
|
||||
$repo->expects($this->once())
|
||||
->method('findByUuid')
|
||||
->with('def-456')
|
||||
->willReturn($tenant);
|
||||
|
||||
$gateway = new AuthTenantGateway($repo);
|
||||
$this->assertSame($tenant, $gateway->findByUuid('def-456'));
|
||||
}
|
||||
|
||||
public function testListDelegatesToRepository(): void
|
||||
{
|
||||
$tenants = [
|
||||
['id' => 1, 'name' => 'Acme Corp'],
|
||||
['id' => 2, 'name' => 'Beta Inc'],
|
||||
];
|
||||
|
||||
$repo = $this->createMock(TenantRepositoryInterface::class);
|
||||
$repo->expects($this->once())
|
||||
->method('list')
|
||||
->willReturn($tenants);
|
||||
|
||||
$gateway = new AuthTenantGateway($repo);
|
||||
$this->assertSame($tenants, $gateway->list());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user