From 8b4cac8795f6308baec6ec64df264aa31a87a6cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 22:31:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=BC=BA=E8=AE=A2=E9=98=85=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E5=B7=B2=E4=BB=98=E6=97=A0=E5=9B=9E=E6=89=A7=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E5=9B=9E=E8=B7=B3=E6=8A=A4=E6=A0=8F=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...kShouldUseSubscriptionShowSelfBackTest.php | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 tests/Feature/AdminSiteSubscriptionShowPaidNoReceiptOrdersLinkShouldUseSubscriptionShowSelfBackTest.php diff --git a/tests/Feature/AdminSiteSubscriptionShowPaidNoReceiptOrdersLinkShouldUseSubscriptionShowSelfBackTest.php b/tests/Feature/AdminSiteSubscriptionShowPaidNoReceiptOrdersLinkShouldUseSubscriptionShowSelfBackTest.php new file mode 100644 index 0000000..7280f26 --- /dev/null +++ b/tests/Feature/AdminSiteSubscriptionShowPaidNoReceiptOrdersLinkShouldUseSubscriptionShowSelfBackTest.php @@ -0,0 +1,74 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_paid_no_receipt_orders_link_should_use_subscription_show_self_as_back(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'sub_show_paid_no_receipt_self_back_plan', + 'name' => '订阅详情已付无回执回跳自环测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 66, + 'list_price' => 66, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $subscription = SiteSubscription::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'status' => 'active', + 'source' => 'manual', + 'subscription_no' => 'SS_SHOW_PNR_SELF_BACK_0001', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'amount' => 66, + 'starts_at' => now()->subDay(), + 'ends_at' => now()->addMonth(), + ]); + + $res = $this->get('/admin/site-subscriptions/' . $subscription->id . '?back=' . urlencode('/admin/platform-orders?payment_status=paid')); + $res->assertOk(); + + $html = (string) $res->getContent(); + $matched = preg_match('/已付无回执订单:\s*]+href="([^"]+)"/u', $html, $m); + $this->assertSame(1, $matched, '未找到订阅详情页“已付无回执订单”链接'); + + $href = html_entity_decode($m[1] ?? ''); + $expectedUrl = '/admin/platform-orders?' . Arr::query([ + 'site_subscription_id' => $subscription->id, + 'payment_status' => 'paid', + 'receipt_status' => 'none', + 'back' => '/admin/site-subscriptions/' . $subscription->id, + ]); + + $this->assertSame($expectedUrl, $href); + $this->assertStringNotContainsString(urlencode('/admin/platform-orders?payment_status=paid'), $href); + } +}