createDefaultThemeConfig(); return new SettingsAppGateway(new SettingsMetadataGateway($settings), $themeConfig); } private function createDefaultThemeConfig(): ThemeConfigGateway { $themeConfig = $this->createMock(ThemeConfigGateway::class); $themeConfig->method('all')->willReturn(['light' => 'Light', 'dark' => 'Dark']); return $themeConfig; } public function testGetAppTitleReturnsNullWhenEmpty(): void { $settings = $this->createMock(SettingRepositoryInterface::class); $settings->expects($this->any())->method('getValue')->with('app_title')->willReturn(null); $gateway = $this->createGateway($settings); $this->assertNull($gateway->getAppTitle()); } public function testGetAppTitleReturnsTrimmedValue(): void { $settings = $this->createMock(SettingRepositoryInterface::class); $settings->expects($this->any())->method('getValue')->with('app_title')->willReturn(' My App '); $gateway = $this->createGateway($settings); $this->assertSame('My App', $gateway->getAppTitle()); } public function testGetAppLocaleReturnsNullWhenNotSet(): void { $settings = $this->createMock(SettingRepositoryInterface::class); $settings->expects($this->any())->method('getValue')->with('app_locale')->willReturn(null); $gateway = $this->createGateway($settings); $this->assertNull($gateway->getAppLocale()); } public function testIsRegistrationEnabledDefaultsToTrue(): void { $settings = $this->createMock(SettingRepositoryInterface::class); $settings->expects($this->any())->method('getValue')->with('app_registration')->willReturn(null); $gateway = $this->createGateway($settings); $this->assertTrue($gateway->isRegistrationEnabled()); } public function testIsRegistrationEnabledReturnsFalseWhenDisabled(): void { $settings = $this->createMock(SettingRepositoryInterface::class); $settings->expects($this->any())->method('getValue')->with('app_registration')->willReturn('0'); $gateway = $this->createGateway($settings); $this->assertFalse($gateway->isRegistrationEnabled()); } public function testGetAppPrimaryColorRejectsInvalidFormat(): void { $settings = $this->createMock(SettingRepositoryInterface::class); $settings->expects($this->any())->method('getValue')->with('app_primary_color')->willReturn('not-a-color'); $gateway = $this->createGateway($settings); $this->assertNull($gateway->getAppPrimaryColor()); } public function testGetAppPrimaryColorReturnsValidHex(): void { $settings = $this->createMock(SettingRepositoryInterface::class); $settings->expects($this->any())->method('getValue')->with('app_primary_color')->willReturn('#ff5500'); $gateway = $this->createGateway($settings); $this->assertSame('#ff5500', $gateway->getAppPrimaryColor()); } public function testIsAllowedThemeReturnsTrueForKnownTheme(): void { $settings = $this->createMock(SettingRepositoryInterface::class); $gateway = $this->createGateway($settings); $this->assertTrue($gateway->isAllowedTheme('dark')); } public function testIsAllowedThemeReturnsFalseForUnknownTheme(): void { $settings = $this->createMock(SettingRepositoryInterface::class); $gateway = $this->createGateway($settings); $this->assertFalse($gateway->isAllowedTheme('neon')); } }