30 lines
1.0 KiB
PHP
30 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Support\AdminFlash;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class AdminFlashWarningPayloadTest extends TestCase
|
|
{
|
|
public function test_warning_should_return_message_only_when_no_link_and_no_copy(): void
|
|
{
|
|
$p = AdminFlash::warning('warn');
|
|
|
|
$this->assertSame('warn', (string) ($p['warning'] ?? ''));
|
|
$this->assertArrayNotHasKey('warning_link_href', $p);
|
|
$this->assertArrayNotHasKey('warning_copy_text', $p);
|
|
}
|
|
|
|
public function test_warning_should_include_link_and_copy_when_provided(): void
|
|
{
|
|
$p = AdminFlash::warning('warn', '/admin/x', '查看', 'ABC', '复制run_id');
|
|
|
|
$this->assertSame('warn', (string) ($p['warning'] ?? ''));
|
|
$this->assertSame('/admin/x', (string) ($p['warning_link_href'] ?? ''));
|
|
$this->assertSame('查看', (string) ($p['warning_link_label'] ?? ''));
|
|
$this->assertSame('ABC', (string) ($p['warning_copy_text'] ?? ''));
|
|
$this->assertSame('复制run_id', (string) ($p['warning_copy_label'] ?? ''));
|
|
}
|
|
}
|