From d4653e952734d56deceef3206643072568411b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Fri, 20 Mar 2026 08:53:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E8=AE=A2=E9=98=85=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E8=BF=94=E5=9B=9E=E5=88=97=E8=A1=A8=E5=85=9C?= =?UTF-8?q?=E5=BA=95=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...scriptionShowIndexLinkKeepsContextTest.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/Feature/AdminSiteSubscriptionShowIndexLinkKeepsContextTest.php b/tests/Feature/AdminSiteSubscriptionShowIndexLinkKeepsContextTest.php index 24f75e3..4598864 100644 --- a/tests/Feature/AdminSiteSubscriptionShowIndexLinkKeepsContextTest.php +++ b/tests/Feature/AdminSiteSubscriptionShowIndexLinkKeepsContextTest.php @@ -75,4 +75,51 @@ class AdminSiteSubscriptionShowIndexLinkKeepsContextTest extends TestCase $res2->assertSee('返回上一页(保留上下文)'); $res2->assertDontSee('返回订阅列表(保留上下文)'); } + + public function test_show_page_should_fall_back_to_subscription_index_link_with_self_back_when_back_is_unsafe(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + + $plan = Plan::query()->create([ + 'code' => 'sub_show_index_link_unsafe_back_test', + 'name' => '订阅详情 unsafe back 兜底返回测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 20, + 'list_price' => 20, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $sub = SiteSubscription::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'status' => 'activated', + 'source' => 'manual', + 'subscription_no' => 'SUB_SHOW_INDEX_LINK_UNSAFE_BACK_0001', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'amount' => 20, + 'starts_at' => now()->subDay(), + 'ends_at' => now()->addMonth(), + 'activated_at' => now()->subDay(), + ]); + + $unsafeBack = '/admin/site-subscriptions?status=active&back=/admin/platform-orders'; + + $res = $this->get('/admin/site-subscriptions/' . $sub->id . '?back=' . urlencode($unsafeBack)); + $res->assertOk(); + + $expectedIndexUrl = '/admin/site-subscriptions?' . Arr::query([ + 'back' => '/admin/site-subscriptions/' . $sub->id, + ]); + + $res->assertDontSee('返回上一页(保留上下文)'); + $res->assertSee('返回订阅列表(保留上下文)'); + $res->assertSee($expectedIndexUrl, false); + $res->assertDontSee('back=' . $unsafeBack, false); + } }