feat: implement global autoresponder plugin
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once PLUGIN_ROOT . '/exec/lib/RuleRepository.php';
|
||||
|
||||
test('rule repository isolates users and stores rules atomically', function (): void {
|
||||
$repo = new RuleRepository(TEST_TMP . '/data');
|
||||
$rule = [
|
||||
'subject' => 'Urlop',
|
||||
'body' => 'Body',
|
||||
'start_ts' => 1,
|
||||
'end_ts' => 2,
|
||||
'enabled' => true,
|
||||
];
|
||||
|
||||
$created = $repo->create('alice', $rule);
|
||||
assert_true(isset($created['id']));
|
||||
assert_same(1, count($repo->all('alice')));
|
||||
assert_same(0, count($repo->all('bob')));
|
||||
|
||||
try {
|
||||
$repo->update('bob', $created['id'], ['subject' => 'Other']);
|
||||
} catch (RuntimeException $e) {
|
||||
assert_contains('not found', $e->getMessage());
|
||||
return;
|
||||
}
|
||||
throw new RuntimeException('Expected cross-user update to fail');
|
||||
});
|
||||
Reference in New Issue
Block a user