40 lines
1.5 KiB
PHP
40 lines
1.5 KiB
PHP
<?php
|
|
/** Регрессия правила: deploy меняет только явно согласованный ключ focus. */
|
|
|
|
declare(strict_types=1);
|
|
|
|
$root = dirname(__DIR__);
|
|
$script = $root . '/bin/ensure-focus-config.php';
|
|
$fixture = [
|
|
'host' => 'custom.example',
|
|
'requisites' => ['Не менять'],
|
|
'utm' => [
|
|
'theme' => ['weights' => ['dark' => 7, 'light' => 3], 'default' => 'light'],
|
|
'focus' => ['weights' => ['center' => 9, 'face' => 1], 'default' => 'center'],
|
|
],
|
|
];
|
|
$path = tempnam(sys_get_temp_dir(), 'preland-config-');
|
|
if ($path === false) {
|
|
fwrite(STDERR, "FAIL: не создан временный config.\n");
|
|
exit(1);
|
|
}
|
|
|
|
try {
|
|
file_put_contents($path, json_encode($fixture, JSON_THROW_ON_ERROR));
|
|
exec(PHP_BINARY . ' ' . escapeshellarg($script) . ' ' . escapeshellarg($path), $output, $code);
|
|
$actual = json_decode((string) file_get_contents($path), true, 512, JSON_THROW_ON_ERROR);
|
|
} finally {
|
|
@unlink($path);
|
|
}
|
|
|
|
if ($code !== 10
|
|
|| ($actual['host'] ?? null) !== 'custom.example'
|
|
|| ($actual['requisites'] ?? null) !== ['Не менять']
|
|
|| ($actual['utm']['theme'] ?? null) !== $fixture['utm']['theme']
|
|
|| ($actual['utm']['focus'] ?? null) !== ['weights' => ['center' => 0, 'face' => 1], 'default' => 'face']) {
|
|
fwrite(STDERR, "FAIL: host-config должен сохранить все значения, кроме явно заданного focus.\n");
|
|
exit(1);
|
|
}
|
|
|
|
fwrite(STDOUT, "OK: host config changes only explicit focus\n");
|