fix: match directadmin vacation controls
This commit is contained in:
@@ -26,21 +26,42 @@ test('rule validator normalizes exact hour schedule', function (): void {
|
||||
assert_true($rule['start_ts'] < $rule['end_ts']);
|
||||
});
|
||||
|
||||
test('rule validator accepts da period schedule when backend is da', function (): void {
|
||||
test('rule validator accepts da exact hour schedule when backend is da', function (): void {
|
||||
$settingsPath = TEST_TMP . '/validator-da.conf';
|
||||
test_write($settingsPath, "GLOBAL_AUTORESPONDER_BACKEND=da\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$rule = RuleValidator::validate([
|
||||
'subject_prefix' => 'Urlop',
|
||||
'reply_frequency' => 'every',
|
||||
'reply_frequency' => '1',
|
||||
'body' => 'Body',
|
||||
'start_value' => '2026-06-10|morning',
|
||||
'end_value' => '2026-06-24|evening',
|
||||
'start_value' => '2026-06-10T00:00',
|
||||
'end_value' => '2026-06-24T23:59',
|
||||
'enabled' => '1',
|
||||
], $settings);
|
||||
assert_same('directadmin_period', $rule['schedule_mode']);
|
||||
assert_true($rule['reply_every_message']);
|
||||
assert_same(0, $rule['repeat_minutes']);
|
||||
assert_same('exact_hour', $rule['schedule_mode']);
|
||||
assert_false($rule['reply_every_message']);
|
||||
assert_same(1, $rule['repeat_minutes']);
|
||||
assert_same('2026-06-10T00:00', $rule['start_value']);
|
||||
assert_same('2026-06-24T23:59', $rule['end_value']);
|
||||
});
|
||||
|
||||
test('rule validator rejects every message frequency for da backend', function (): void {
|
||||
$settingsPath = TEST_TMP . '/validator-da-every.conf';
|
||||
test_write($settingsPath, "GLOBAL_AUTORESPONDER_BACKEND=da\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
try {
|
||||
RuleValidator::validate([
|
||||
'subject_prefix' => 'Urlop',
|
||||
'reply_frequency' => 'every',
|
||||
'body' => 'Body',
|
||||
'start_value' => '2026-06-10T00:00',
|
||||
'end_value' => '2026-06-24T23:59',
|
||||
], $settings);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
assert_contains('Częstość odpowiedzi', $e->getMessage());
|
||||
return;
|
||||
}
|
||||
throw new RuntimeException('Expected every-message frequency to fail for da backend');
|
||||
});
|
||||
|
||||
test('rule validator rejects header injection and reversed dates', function (): void {
|
||||
@@ -66,8 +87,8 @@ test('rule validator rejects unsupported response frequency', function (): void
|
||||
'subject_prefix' => 'Urlop',
|
||||
'reply_frequency' => '45',
|
||||
'body' => 'Body',
|
||||
'start_value' => '2026-06-10|morning',
|
||||
'end_value' => '2026-06-24|evening',
|
||||
'start_value' => '2026-06-10T00:00',
|
||||
'end_value' => '2026-06-24T23:59',
|
||||
], $settings);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
assert_contains('Częstość odpowiedzi', $e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user