refactor(batch): 去重阻断warning组装提炼BatchDispatchWarning并加单测
This commit is contained in:
36
tests/Unit/BatchDispatchWarningBuildTest.php
Normal file
36
tests/Unit/BatchDispatchWarningBuildTest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Support\BatchDispatchWarning;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BatchDispatchWarningBuildTest extends TestCase
|
||||
{
|
||||
public function test_build_should_include_run_id_in_warning_and_actions_when_run_id_present(): void
|
||||
{
|
||||
$flash = BatchDispatchWarning::build('BAS ', 'BAS202603171234560001', 'bas');
|
||||
|
||||
$this->assertIsArray($flash);
|
||||
$this->assertArrayHasKey('warning', $flash);
|
||||
$this->assertStringContainsString('run_id=', (string) $flash['warning']);
|
||||
|
||||
$this->assertSame('进入上次批次复盘', (string) ($flash['warning_link_label'] ?? ''));
|
||||
$this->assertStringContainsString('type=bas', (string) ($flash['warning_link_href'] ?? ''));
|
||||
|
||||
$this->assertSame('BAS202603171234560001', (string) ($flash['warning_copy_text'] ?? ''));
|
||||
$this->assertSame('复制run_id', (string) ($flash['warning_copy_label'] ?? ''));
|
||||
}
|
||||
|
||||
public function test_build_should_not_include_actions_when_run_id_missing(): void
|
||||
{
|
||||
$flash = BatchDispatchWarning::build('BMPA ', '', 'bmpa');
|
||||
|
||||
$this->assertIsArray($flash);
|
||||
$this->assertArrayHasKey('warning', $flash);
|
||||
$this->assertStringNotContainsString('run_id=', (string) $flash['warning']);
|
||||
|
||||
$this->assertArrayNotHasKey('warning_link_href', $flash);
|
||||
$this->assertArrayNotHasKey('warning_copy_text', $flash);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user