instances added god may help

This commit is contained in:
2026-02-23 12:58:19 +01:00
parent 25370a1a55
commit 99db252f60
290 changed files with 9858 additions and 4914 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace MintyPHP\Tests\Service\Settings;
use MintyPHP\Service\Settings\SettingCacheService;
use PHPUnit\Framework\TestCase;
class SettingCacheServiceTest extends TestCase
{
public function testGetReturnsNullForMissingKey(): void
{
$file = $this->tempFilePath();
file_put_contents($file, "<?php\nreturn ['app_title' => 'Demo'];\n");
$service = new SettingCacheService($file);
$this->assertNull($service->get('missing'));
}
public function testUpdateWritesAndNormalizesValues(): void
{
$file = $this->tempFilePath();
file_put_contents($file, "<?php\nreturn ['app_title' => 'Old'];\n");
$service = new SettingCacheService($file);
$this->assertTrue($service->update([
'app_title' => 'New',
'app_locale' => null,
]));
$this->assertSame('New', $service->get('app_title'));
$this->assertNull($service->get('app_locale'));
}
private function tempFilePath(): string
{
$dir = sys_get_temp_dir() . '/mintyphp_settings_cache_test_' . bin2hex(random_bytes(6));
mkdir($dir, 0775, true);
$file = $dir . '/settings.php';
$this->addToAssertionCount(1);
$this->assertDirectoryExists($dir);
return $file;
}
}