Files
breadcrumb-the-shire/tests/Service/Auth/AuthTenantGatewayTest.php
fs 98afac24b1 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>
2026-04-13 20:46:20 +02:00

67 lines
2.0 KiB
PHP

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