39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
||
|
||
namespace Tests\Feature;
|
||
|
||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||
use Tests\TestCase;
|
||
|
||
class AdminDashboardRecentPlatformOrderLinksShouldCarryBackTest extends TestCase
|
||
{
|
||
use RefreshDatabase;
|
||
|
||
protected function loginAsPlatformAdmin(): void
|
||
{
|
||
$this->seed();
|
||
|
||
$this->post('/admin/login', [
|
||
'email' => 'platform.admin@demo.local',
|
||
'password' => 'Platform@123456',
|
||
])->assertRedirect('/admin');
|
||
}
|
||
|
||
public function test_dashboard_recent_platform_order_links_should_carry_back(): void
|
||
{
|
||
$this->loginAsPlatformAdmin();
|
||
|
||
$res = $this->get('/admin');
|
||
$res->assertOk();
|
||
|
||
$html = (string) $res->getContent();
|
||
|
||
// 从仪表盘点进订单详情后,应能通过 back 回到 /admin
|
||
// 备注:订单 ID 不应被测试写死(seed 数据可能调整)。这里只校验“任意一条详情链接”携带 back=%2Fadmin。
|
||
$this->assertMatchesRegularExpression('/href="\\/admin\\/platform-orders\\/\\d+\\?back=%2Fadmin"/', $html);
|
||
|
||
// back 必须是一次性的(避免 nested back / HTML & 泄露)
|
||
$res->assertDontSee('&back=', false);
|
||
}
|
||
}
|