Files
saasshop/tests/Feature/AdminDashboardRecentPlatformOrderLinksShouldCarryBackTest.php

39 lines
1.2 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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 &amp; 泄露)
$res->assertDontSee('&amp;back=', false);
}
}