From db4d74be7a90c7df46efe2015e45a1e009fcd800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Fri, 20 Mar 2026 08:55:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E5=B9=B3=E5=8F=B0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E8=AF=A6=E6=83=85=E9=A1=B5=E8=BF=94=E5=9B=9E=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=85=9C=E5=BA=95=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...formOrderShowIndexLinkKeepsContextTest.php | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/Feature/AdminPlatformOrderShowIndexLinkKeepsContextTest.php b/tests/Feature/AdminPlatformOrderShowIndexLinkKeepsContextTest.php index 740da79..49b1992 100644 --- a/tests/Feature/AdminPlatformOrderShowIndexLinkKeepsContextTest.php +++ b/tests/Feature/AdminPlatformOrderShowIndexLinkKeepsContextTest.php @@ -84,4 +84,53 @@ class AdminPlatformOrderShowIndexLinkKeepsContextTest extends TestCase $res3->assertSee('← 返回上一页(保留上下文)'); $res3->assertDontSee('返回平台订单列表(保留上下文)'); } + + public function test_show_page_should_fall_back_to_platform_order_index_link_with_self_back_when_back_is_unsafe(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + + $plan = Plan::query()->create([ + 'code' => 'po_show_index_link_unsafe_back_plan', + 'name' => '平台订单详情 unsafe back 兜底返回测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $order = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_SHOW_INDEX_LINK_UNSAFE_BACK_0001', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'unpaid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 0, + 'placed_at' => now(), + 'meta' => [], + ]); + + $unsafeBack = '/admin/platform-orders?status=pending&back=/admin'; + + $res = $this->get('/admin/platform-orders/' . $order->id . '?back=' . urlencode($unsafeBack)); + $res->assertOk(); + + $expectedIndexUrl = '/admin/platform-orders?' . Arr::query([ + 'back' => '/admin/platform-orders/' . $order->id, + ]); + + $res->assertDontSee('← 返回上一页(保留上下文)'); + $res->assertSee('返回平台订单列表(保留上下文)'); + $res->assertSee($expectedIndexUrl, false); + $res->assertDontSee('back=' . $unsafeBack, false); + } }