37 lines
1.4 KiB
PHP
37 lines
1.4 KiB
PHP
<?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);
|
|
}
|
|
}
|