Files
Enelix-EMS/services/netplan-v4/acceptance/php-src/check.php
T

46 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
// OFFLINE ONLY: no Symcon kernel, HTTP requests, timers or connected devices.
if (PHP_SAPI !== 'cli' || function_exists('IPS_GetVariable')) {
fwrite(STDERR, "This is an isolated CLI test, not a Symcon runtime script.\n");
exit(2);
}
set_error_handler(static function (int $severity, string $message, string $file, int $line): bool {
throw new ErrorException($message, 0, $severity, $file, $line);
});
try {
$manifest = json_decode(file_get_contents(__DIR__ . '/SOURCE_MANIFEST.json'), true, 512, JSON_THROW_ON_ERROR);
foreach ($manifest as $relative => $expected) {
$path = __DIR__ . '/' . $relative;
if (!is_file($path) || hash_file('sha256', $path) !== $expected) {
throw new RuntimeException('Source manifest mismatch: ' . $relative);
}
$command = escapeshellarg(PHP_BINARY) . ' -l ' . escapeshellarg($path);
$lines = [];
exec($command, $lines, $code);
if ($code !== 0) {
throw new RuntimeException('PHP syntax failure: ' . $relative);
}
}
require __DIR__ . '/libs/NetzfahrplanV4Bezugszaehler.php';
require __DIR__ . '/libs/NetzfahrplanV4Betriebsdaten.php';
require __DIR__ . '/libs/ManagerNetzfahrplanV4Trait.php';
require __DIR__ . '/tests/fixtures/NativeV4Scenarios.php';
require __DIR__ . '/tests/fixtures/V4BezugszaehlerScenarios.php';
$native = \Belevo\EnelixEMS\Tests\NativeV4Scenarios::run();
$meters = \Belevo\EnelixEMS\Tests\V4BezugszaehlerScenarios::run();
if (count($native) !== 24 || count($meters) !== 20) {
throw new RuntimeException('Expected 24 native and 20 meter scenarios.');
}
foreach (array_merge($native, $meters) as $name) {
echo 'PASS ', $name, "\n";
}
echo 'PHP ', PHP_VERSION, ': 44 offline conversion scenarios passed.', "\n";
echo "NOT a full EMS suite and NOT an IP-Symcon runtime/physical test.\n";
} catch (Throwable $error) {
fwrite(STDERR, 'FAIL: ' . $error->getMessage() . "\n");
exit(1);
}