b94c4152f8
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
48 lines
1.8 KiB
PHP
48 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Mail\SupplierDeadlineWarningMail;
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use Tests\Concerns\SharesSupplierPdo;
|
|
|
|
uses(DatabaseTransactions::class, SharesSupplierPdo::class);
|
|
|
|
beforeEach(function (): void {
|
|
DB::connection('pgsql_supplier')->table('supplier_sync_runs')->delete();
|
|
});
|
|
|
|
it('робот сегодня закончил → сторож молчит', function (): void {
|
|
Mail::fake();
|
|
DB::connection('pgsql_supplier')->table('supplier_sync_runs')->insert([
|
|
'started_at' => now(), 'finished_at' => now(), 'groups_total' => 1, 'synced_ok' => 1,
|
|
'manual_queued' => 0, 'deferred' => 0, 'failed' => 0, 'status' => 'ok', 'created_at' => now(),
|
|
]);
|
|
|
|
$this->artisan('supplier:deadline-watch', ['level' => 'yellow'])->assertExitCode(0);
|
|
|
|
Mail::assertNothingQueued();
|
|
});
|
|
|
|
it('робот сегодня НЕ закончил → красное письмо', function (): void {
|
|
Mail::fake();
|
|
DB::connection('pgsql_supplier')->table('supplier_sync_runs')->insert([
|
|
'started_at' => now(), 'finished_at' => null, 'groups_total' => 0, 'synced_ok' => 0,
|
|
'manual_queued' => 0, 'deferred' => 0, 'failed' => 0, 'status' => 'ok', 'created_at' => now(),
|
|
]);
|
|
|
|
$this->artisan('supplier:deadline-watch', ['level' => 'red'])->assertExitCode(0);
|
|
|
|
Mail::assertQueued(SupplierDeadlineWarningMail::class, fn ($m) => $m->level === 'red');
|
|
});
|
|
|
|
it('запуска за сегодня нет вовсе → письмо (планировщик не сработал)', function (): void {
|
|
Mail::fake();
|
|
|
|
$this->artisan('supplier:deadline-watch', ['level' => 'yellow'])->assertExitCode(0);
|
|
|
|
Mail::assertQueued(SupplierDeadlineWarningMail::class, fn ($m) => $m->level === 'yellow');
|
|
});
|