Fix: testy + bugfix SettingsRepository::allSettings() + migracja phpunit.xml
- SettingsRepository::allSettings() — inicjalizacja $settings = [] przed pętlą (bug: false ?? [] zwracało false gdy cache pusty a DB null) - Stuby wydzielone do tests/stubs/CacheHandler.php + S.php - phpunit.xml zmigurowany do schematu PHPUnit 10 (coverage → source) - composer.lock dodany do repozytorium Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,51 +1,21 @@
|
||||
<?php
|
||||
|
||||
// Medoo ORM — potrzebny do mockowania w testach
|
||||
// Medoo ORM
|
||||
require_once __DIR__ . '/../libraries/medoo/medoo.php';
|
||||
|
||||
// Stub: \Shared\Cache\CacheHandler — musi być załadowany PRZED autoloaderem
|
||||
// żeby nie nadpisała go prawdziwa klasa
|
||||
namespace Shared\Cache {
|
||||
class CacheHandler
|
||||
{
|
||||
private static array $store = [];
|
||||
// Stuby — muszą być załadowane PRZED autoloaderem PSR-4,
|
||||
// żeby nie zostały nadpisane przez prawdziwe klasy
|
||||
require_once __DIR__ . '/stubs/CacheHandler.php';
|
||||
require_once __DIR__ . '/stubs/S.php';
|
||||
|
||||
public static function reset(): void { self::$store = []; }
|
||||
|
||||
public static function fetch(string $key): mixed
|
||||
{
|
||||
return self::$store[$key] ?? false;
|
||||
}
|
||||
|
||||
public static function store(string $key, mixed $value, int $ttl = 0): void
|
||||
{
|
||||
self::$store[$key] = $value;
|
||||
}
|
||||
|
||||
public static function delete(string $key): void
|
||||
{
|
||||
unset(self::$store[$key]);
|
||||
// PSR-4 autoloader dla Domain\
|
||||
// Shared\ jest obsłużona przez stub powyżej — pomijamy w autoloaderze
|
||||
spl_autoload_register(function (string $class): void {
|
||||
if (strncmp($class, 'Domain\\', 7) === 0) {
|
||||
$rel = substr($class, 7);
|
||||
$file = __DIR__ . '/../autoload/Domain/' . str_replace('\\', '/', $rel) . '.php';
|
||||
if (file_exists($file)) {
|
||||
require $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Stub: \S — metody statyczne używane przez repozytoria
|
||||
namespace {
|
||||
class S
|
||||
{
|
||||
public static function delete_cache(): void {}
|
||||
public static function htacces(): void {}
|
||||
public static function get_domain(string $domain = ''): ?string { return $domain ?: null; }
|
||||
public static function send_email(string $to, string $subject, string $body): bool { return true; }
|
||||
}
|
||||
|
||||
// PSR-4 autoloader dla Domain\
|
||||
// Shared\ jest już obsłużona przez stubę powyżej — pomijamy ją w autoloaderze
|
||||
spl_autoload_register(function (string $class): void {
|
||||
if (strncmp($class, 'Domain\\', 7) === 0) {
|
||||
$rel = substr($class, 7);
|
||||
$file = __DIR__ . '/../autoload/Domain/' . str_replace('\\', '/', $rel) . '.php';
|
||||
if (file_exists($file)) { require $file; }
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user