Files
global-autoresponder/tests/package_contents_test.php
T
2026-07-04 15:16:50 +02:00

68 lines
2.8 KiB
PHP

<?php
declare(strict_types=1);
test('packing guidelines exclude docs and allow later manual icon', function (): void {
$packing = file_get_contents(dirname(__DIR__, 2) . '/PACKING.md') ?: '';
assert_contains('docs/dokumentacja.html', $packing);
assert_contains('must not contain `docs/`', $packing);
assert_contains('may be added later at `src/images/user_icon.svg`', $packing);
assert_contains("scripts/package.sh", $packing);
});
test('plugin metadata runs user level as root on directadmin 1.689 plus', function (): void {
$conf = file_get_contents(PLUGIN_ROOT . '/plugin.conf') ?: '';
assert_contains('type=user', $conf);
assert_contains('user_run_as=root', $conf);
});
test('shipped plugin files do not contain placeholders', function (): void {
$bad = [];
$root = new RecursiveDirectoryIterator(PLUGIN_ROOT, FilesystemIterator::SKIP_DOTS);
$it = new RecursiveIteratorIterator($root);
foreach ($it as $file) {
if (!$file->isFile()) {
continue;
}
$path = $file->getPathname();
$relative = substr($path, strlen(PLUGIN_ROOT) + 1);
if (str_starts_with($relative, '.git/') || str_starts_with($relative, 'tests/')) {
continue;
}
$content = file_get_contents($path) ?: '';
if (preg_match('/placeholder|TODO|FIXME|not implemented|stub/i', $content)) {
$bad[] = $relative;
}
}
assert_same([], $bad);
});
test('package source does not ship removed custom mail integration files', function (): void {
$removedPaths = [
'scripts/' . 'back' . 'end.sh',
'scripts/' . 'ex' . 'im',
'scripts/global_auto' . 'responder_worker.php',
'exec/lib/Back' . 'endRuntimeConfig.php',
'exec/lib/Message' . 'Classifier.php',
'exec/lib/Mail' . 'Sender.php',
'exec/lib/Repeat' . 'State.php',
];
foreach ($removedPaths as $relative) {
$path = PLUGIN_ROOT . '/' . $relative;
assert_false(is_file($path) || is_dir($path), $relative . ' must not exist');
}
});
test('lifecycle scripts install directadmin sync cron only', function (): void {
$install = file_get_contents(PLUGIN_ROOT . '/scripts/install.sh') ?: '';
$update = file_get_contents(PLUGIN_ROOT . '/scripts/update.sh') ?: '';
$uninstall = file_get_contents(PLUGIN_ROOT . '/scripts/uninstall.sh') ?: '';
assert_contains('/etc/cron.d/global-autoresponder', $install);
assert_contains('sync_directadmin_vacations.php', $install);
assert_contains('/etc/cron.d/global-autoresponder', $update);
assert_contains('sync_directadmin_vacations.php', $update);
assert_false(str_contains($install, 'back' . 'end-state.json'));
assert_false(str_contains($install, 'state/' . 'replies'));
assert_false(str_contains($uninstall, 'back' . 'end.sh'));
});