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:
2026-04-13 20:46:20 +02:00
parent ea0b31ba67
commit 98afac24b1
12 changed files with 1221 additions and 0 deletions

View 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());
}
}