Sync global-autoresponder current state

This commit is contained in:
Marek Miklewicz
2026-07-04 15:16:50 +02:00
parent 196ee224fe
commit af775ce976
47 changed files with 1165 additions and 1037 deletions
+19 -13
View File
@@ -10,7 +10,6 @@ test('settings validate defaults and external paths', function (): void {
'DEFAULT_PLUGIN_LANGUAGE=pl',
'DEFAULT_ENABLE=false',
'GLOBAL_AUTORESPONDER_TIMEZONE=Europe/Warsaw',
'GLOBAL_AUTORESPONDER_BACKEND=exim',
'GLOBAL_AUTORESPONDER_DYNAMIC_MAILBOX_SCOPE=true',
'GLOBAL_AUTORESPONDER_MAX_SUBJECT_BYTES=255',
'GLOBAL_AUTORESPONDER_MAX_BODY_BYTES=20000',
@@ -21,7 +20,6 @@ test('settings validate defaults and external paths', function (): void {
assert_false($settings->defaultEnable());
assert_same('Europe/Warsaw', $settings->timezone());
assert_same('exact_hour', $settings->scheduleMode());
assert_same('exim', $settings->backendMode());
assert_same('/usr/local/hitme_plugins/global-autoresponders/config', Settings::CONFIG_DIR);
assert_same('/usr/local/hitme_plugins/global-autoresponders/data', Settings::DATA_DIR);
});
@@ -34,7 +32,7 @@ test('settings template does not contain global repeat policy settings', functio
test('settings reject invalid timezone and schedule mode', function (): void {
$path = TEST_TMP . '/bad-settings.conf';
test_write($path, "GLOBAL_AUTORESPONDER_TIMEZONE=Not/AZone\nGLOBAL_AUTORESPONDER_BACKEND=bad\n");
test_write($path, "GLOBAL_AUTORESPONDER_TIMEZONE=Not/AZone\n");
try {
Settings::load($path);
} catch (InvalidArgumentException $e) {
@@ -44,16 +42,8 @@ test('settings reject invalid timezone and schedule mode', function (): void {
throw new RuntimeException('Expected invalid settings to fail');
});
test('backend mode derives schedule mode', function (): void {
$path = TEST_TMP . '/backend.conf';
test_write($path, "GLOBAL_AUTORESPONDER_BACKEND=da\n");
$settings = Settings::load($path);
assert_same('da', $settings->backendMode());
assert_same('exact_hour', $settings->scheduleMode());
test_write($path, "GLOBAL_AUTORESPONDER_BACKEND=exim\n");
$settings = Settings::load($path);
assert_same('exim', $settings->backendMode());
test('settings keep exact schedule mode', function (): void {
$settings = Settings::load(TEST_TMP . '/schedule.conf');
assert_same('exact_hour', $settings->scheduleMode());
});
@@ -67,3 +57,19 @@ test('directadmin user access follows DEFAULT_ENABLE and per-user overrides', fu
test_write(TEST_TMP . '/config/users/marek.conf', "enabled=true\n");
assert_true($user->hasPluginAccess($settings));
});
test('directadmin user normalizes evolution skin variants', function (): void {
assert_same('evolution', (new DirectAdminUser('marek', 'Evolution', 'en', TEST_TMP . '/config'))->skin());
assert_same('evolution', (new DirectAdminUser('marek', 'evolution-ui', 'en', TEST_TMP . '/config'))->skin());
assert_same('enhanced', (new DirectAdminUser('marek', '', 'en', TEST_TMP . '/config'))->skin());
});
test('directadmin user checks common skin environment variables', function (): void {
$source = file_get_contents(PLUGIN_ROOT . '/exec/lib/DirectAdminUser.php') ?: '';
assert_contains('SESSION_SKIN', $source);
assert_contains('SESSION_SELECTED_SKIN', $source);
assert_contains('DA_SKIN', $source);
assert_contains("['skin']", $source);
assert_contains('readUserConf', $source);
});