From 4aa3321162a6a3fb735f927ed11a05022976a671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 06:59:49 +0800 Subject: [PATCH] Site subscription show: guardrail for BAS/BMPA run_id batch replay links --- ...dShouldLinkToPlatformBatchShowPageTest.php | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 tests/Feature/AdminSiteSubscriptionShowBatchRunIdShouldLinkToPlatformBatchShowPageTest.php diff --git a/tests/Feature/AdminSiteSubscriptionShowBatchRunIdShouldLinkToPlatformBatchShowPageTest.php b/tests/Feature/AdminSiteSubscriptionShowBatchRunIdShouldLinkToPlatformBatchShowPageTest.php new file mode 100644 index 0000000..c7c33d7 --- /dev/null +++ b/tests/Feature/AdminSiteSubscriptionShowBatchRunIdShouldLinkToPlatformBatchShowPageTest.php @@ -0,0 +1,95 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_site_subscription_show_page_batch_run_id_should_link_to_platform_batch_show_page(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + + $plan = Plan::query()->create([ + 'code' => 'sub_show_batch_run_id_plan_01', + 'name' => '订阅详情批次run_id链接测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $subscription = SiteSubscription::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'subscription_no' => 'SUB_SHOW_BATCH_RUN_ID_0001', + 'status' => 'active', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'amount' => 10, + 'starts_at' => now()->subDays(1), + 'ends_at' => now()->addDays(30), + 'activated_at' => now()->subDays(1), + ]); + + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'site_subscription_id' => $subscription->id, + 'order_no' => 'PO_SUB_SHOW_BATCH_RUN_ID_0001', + 'order_type' => 'renewal', + 'status' => 'activated', + 'payment_status' => 'paid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 10, + 'placed_at' => now(), + 'paid_at' => now(), + 'activated_at' => now(), + 'meta' => [ + 'batch_activation' => [ + 'run_id' => 'RUN_BAS_SUB_0001', + ], + 'batch_mark_paid_and_activate' => [ + 'run_id' => 'RUN_BMPA_SUB_0001', + ], + ], + ]); + + $res = $this->get('/admin/site-subscriptions/' . $subscription->id); + $res->assertOk(); + + // BAS/BMPA run_id 在订阅详情页应可点击直达批次复盘页(携带 back 回到订阅详情)。 + $res->assertSee('RUN_BAS_SUB_0001', false); + $res->assertSee('/admin/platform-batches/show?type=bas&run_id=RUN_BAS_SUB_0001', false); + $res->assertSee('back=%2Fadmin%2Fsite-subscriptions%2F' . $subscription->id, false); + + $res->assertSee('RUN_BMPA_SUB_0001', false); + $res->assertSee('/admin/platform-batches/show?type=bmpa&run_id=RUN_BMPA_SUB_0001', false); + } +}