15 lines
684 B
PHP
15 lines
684 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once PLUGIN_ROOT . '/exec/lib/RepeatState.php';
|
|
|
|
test('repeat state allows first reply and blocks repeated reply until ttl', function (): void {
|
|
$state = new RepeatState(TEST_TMP . '/state', 1000);
|
|
assert_true($state->shouldSend('alice', 'rule', 'info@example.com', 'sender@example.com', 60));
|
|
$state->record('alice', 'rule', 'info@example.com', 'sender@example.com');
|
|
assert_false($state->shouldSend('alice', 'rule', 'info@example.com', 'sender@example.com', 60));
|
|
|
|
$later = new RepeatState(TEST_TMP . '/state', 5000);
|
|
assert_true($later->shouldSend('alice', 'rule', 'info@example.com', 'sender@example.com', 60));
|
|
});
|