refactor(admin): success flash payload提炼AdminFlash::success并复用
This commit is contained in:
26
tests/Unit/AdminFlashSuccessPayloadTest.php
Normal file
26
tests/Unit/AdminFlashSuccessPayloadTest.php
Normal 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'] ?? ''));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user