Files
portal/app/tests/Unit/External/SmtpLivenessProbeTest.php
T

27 lines
905 B
PHP
Raw Normal View History

<?php
declare(strict_types=1);
use App\Services\External\SmtpLivenessProbe;
it('зелёный, когда сокет открылся и вернул баннер 220', function () {
$probe = new SmtpLivenessProbe(fn () => "220 smtp.yandex.ru ESMTP\r\n");
$r = $probe->check();
expect($r->serviceKey)->toBe('email');
expect($r->light)->toBe('green');
});
it('красный, когда соединитель бросил (порт недоступен)', function () {
$probe = new SmtpLivenessProbe(function () {
throw new RuntimeException('Connection refused');
});
$r = $probe->check();
expect($r->light)->toBe('red');
expect($r->detail)->toContain('refused');
});
it('красный, когда баннер не 220', function () {
$probe = new SmtpLivenessProbe(fn () => "554 blocked\r\n");
expect($probe->check()->light)->toBe('red');
});