Migriert die weiterhin benötigten Zeitaufgaben einschließlich SOAP-Importen, Betriebsstatus und Wiederanlaufkontrolle. Aktiviert 115 native Spring-Tasks im Docker-Image ohne Cron-Daemon oder PHP und dokumentiert die entfallenen HHA-Aufrufe. Ergänzt PHP-/UI-Testwerkzeuge und aktualisiert den Projektstand auf Version 0.2.0.
91 lines
2.7 KiB
PHP
91 lines
2.7 KiB
PHP
<?php
|
|
|
|
final class FixtureState
|
|
{
|
|
public static array $parameters = [];
|
|
public static array $serviceCalls = [];
|
|
public static array $writes = [];
|
|
public static array $logs = [];
|
|
|
|
public static function reset(): void
|
|
{
|
|
self::$parameters = [];
|
|
self::$serviceCalls = [];
|
|
self::$writes = [];
|
|
self::$logs = [];
|
|
$GLOBALS['db'] = new FixtureDatabase();
|
|
$GLOBALS['hq_id'] = 7;
|
|
$GLOBALS['phpVersion'] = '8.2';
|
|
$GLOBALS['ph'] = [];
|
|
}
|
|
}
|
|
|
|
final class FixtureDatabase
|
|
{
|
|
public array $expected = [];
|
|
|
|
public function expect(string $method, string $sql, mixed $result): void
|
|
{
|
|
$this->expected[] = [$method, $sql, $result];
|
|
}
|
|
|
|
public function __call(string $method, array $arguments): mixed
|
|
{
|
|
if (!$this->expected) {
|
|
throw new RuntimeException('Unexpected database operation: ' . $method);
|
|
}
|
|
[$expectedMethod, $expectedSql, $result] = array_shift($this->expected);
|
|
if ($method !== $expectedMethod || $arguments !== [$expectedSql]) {
|
|
throw new RuntimeException('Unexpected fixture query: ' . $method . ' ' . ($arguments[0] ?? ''));
|
|
}
|
|
return $result;
|
|
}
|
|
}
|
|
|
|
final class FixtureRows
|
|
{
|
|
private int $index = 0;
|
|
public bool $freed = false;
|
|
public function __construct(private array $rows) {}
|
|
public function fetch_assoc(): ?array { return $this->rows[$this->index++] ?? null; }
|
|
public function fetchRow(): ?array { return $this->fetch_assoc(); }
|
|
public function free(): void { $this->freed = true; }
|
|
}
|
|
|
|
final class DB
|
|
{
|
|
public static function isError(mixed $value): bool { return $value instanceof Throwable; }
|
|
}
|
|
|
|
function getParameterValue($employee, $key, $hq)
|
|
{
|
|
if (!in_array($key, ['DB_FIELDTYPE_WRAPPER_1', 'COUNTRY_FON_PREFIX',
|
|
'INV_PRINT_DISCOUNT', 'INV_USE_EURO_SIGN', 'MASK_MARKUP_MODE'], true)) {
|
|
throw new RuntimeException('Unexpected parameter: ' . $key);
|
|
}
|
|
return FixtureState::$parameters[$hq][$key] ?? '';
|
|
}
|
|
|
|
function getServiceValues(...$arguments)
|
|
{
|
|
if (!FixtureState::$serviceCalls) {
|
|
throw new RuntimeException('Unexpected service lookup');
|
|
}
|
|
[$expected, $result] = array_shift(FixtureState::$serviceCalls);
|
|
if ($arguments !== $expected) {
|
|
throw new RuntimeException('Service lookup arguments differ: ' . json_encode($arguments));
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
function insertStmt($table, $row)
|
|
{
|
|
if ($table !== 'phoenix_log.b2b_objects') {
|
|
throw new RuntimeException('Unexpected write target: ' . $table);
|
|
}
|
|
FixtureState::$writes[] = [$table, $row];
|
|
}
|
|
|
|
function writeLog_($file, $message) { FixtureState::$logs[] = [$file, $message]; }
|
|
function reportDie($message) { throw new RuntimeException($message); }
|