feat(external): SmtpLivenessProbe — живость почты Yandex 360

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Дмитрий
2026-07-02 07:50:16 +03:00
parent 9fd4459e2f
commit 5e8e58d1d1
3 changed files with 99 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
<?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');
});