Files
breadcrumb-the-shire/tests/Service/Directory/DirectorySettingsGatewayTest.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

116 lines
3.8 KiB
PHP

<?php
namespace MintyPHP\Tests\Service\Directory;
use MintyPHP\Service\Directory\DirectorySettingsGateway;
use MintyPHP\Service\Settings\SettingsAppGateway;
use MintyPHP\Service\Settings\SettingsDefaultsGateway;
use PHPUnit\Framework\TestCase;
class DirectorySettingsGatewayTest extends TestCase
{
public function testSetDefaultTenantIdDelegatesToSettingsDefaultsGateway(): void
{
$defaults = $this->createMock(SettingsDefaultsGateway::class);
$defaults->expects($this->once())
->method('setDefaultTenantId')
->with(42);
$app = $this->createMock(SettingsAppGateway::class);
$gateway = new DirectorySettingsGateway($defaults, $app);
$gateway->setDefaultTenantId(42);
}
public function testSetDefaultTenantIdAcceptsNull(): void
{
$defaults = $this->createMock(SettingsDefaultsGateway::class);
$defaults->expects($this->once())
->method('setDefaultTenantId')
->with(null);
$app = $this->createMock(SettingsAppGateway::class);
$gateway = new DirectorySettingsGateway($defaults, $app);
$gateway->setDefaultTenantId(null);
}
public function testSetDefaultDepartmentIdDelegatesToSettingsDefaultsGateway(): void
{
$defaults = $this->createMock(SettingsDefaultsGateway::class);
$defaults->expects($this->once())
->method('setDefaultDepartmentId')
->with(7);
$app = $this->createMock(SettingsAppGateway::class);
$gateway = new DirectorySettingsGateway($defaults, $app);
$gateway->setDefaultDepartmentId(7);
}
public function testSetDefaultDepartmentIdAcceptsNull(): void
{
$defaults = $this->createMock(SettingsDefaultsGateway::class);
$defaults->expects($this->once())
->method('setDefaultDepartmentId')
->with(null);
$app = $this->createMock(SettingsAppGateway::class);
$gateway = new DirectorySettingsGateway($defaults, $app);
$gateway->setDefaultDepartmentId(null);
}
public function testSetDefaultRoleIdDelegatesToSettingsDefaultsGateway(): void
{
$defaults = $this->createMock(SettingsDefaultsGateway::class);
$defaults->expects($this->once())
->method('setDefaultRoleId')
->with(3);
$app = $this->createMock(SettingsAppGateway::class);
$gateway = new DirectorySettingsGateway($defaults, $app);
$gateway->setDefaultRoleId(3);
}
public function testSetDefaultRoleIdAcceptsNull(): void
{
$defaults = $this->createMock(SettingsDefaultsGateway::class);
$defaults->expects($this->once())
->method('setDefaultRoleId')
->with(null);
$app = $this->createMock(SettingsAppGateway::class);
$gateway = new DirectorySettingsGateway($defaults, $app);
$gateway->setDefaultRoleId(null);
}
public function testIsAllowedThemeDelegatesToSettingsAppGateway(): void
{
$defaults = $this->createMock(SettingsDefaultsGateway::class);
$app = $this->createMock(SettingsAppGateway::class);
$app->expects($this->once())
->method('isAllowedTheme')
->with('dark')
->willReturn(true);
$gateway = new DirectorySettingsGateway($defaults, $app);
$this->assertTrue($gateway->isAllowedTheme('dark'));
}
public function testIsAllowedThemeReturnsFalseForUnknownTheme(): void
{
$defaults = $this->createMock(SettingsDefaultsGateway::class);
$app = $this->createMock(SettingsAppGateway::class);
$app->expects($this->once())
->method('isAllowedTheme')
->with('neon')
->willReturn(false);
$gateway = new DirectorySettingsGateway($defaults, $app);
$this->assertFalse($gateway->isAllowedTheme('neon'));
}
}