refactor(admin): success flash payload提炼AdminFlash::success并复用

This commit is contained in:
萝卜
2026-03-17 18:56:14 +08:00
parent ea70f24535
commit 3f471aa8db
3 changed files with 95 additions and 12 deletions

View File

@@ -0,0 +1,26 @@
<?php
namespace Tests\Unit;
use App\Support\AdminFlash;
use PHPUnit\Framework\TestCase;
class AdminFlashSuccessPayloadTest extends TestCase
{
public function test_success_should_return_message_only_when_no_link(): void
{
$p = AdminFlash::success('ok');
$this->assertSame('ok', (string) ($p['success'] ?? ''));
$this->assertArrayNotHasKey('success_link_href', $p);
}
public function test_success_should_include_link_when_href_present(): void
{
$p = AdminFlash::success('ok', '/admin/x', '查看');
$this->assertSame('ok', (string) ($p['success'] ?? ''));
$this->assertSame('/admin/x', (string) ($p['success_link_href'] ?? ''));
$this->assertSame('查看', (string) ($p['success_link_label'] ?? ''));
}
}