From af8665ec7d8de7e35ee04aa516390bdbfb44490f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sun, 15 Mar 2026 07:39:06 +0000 Subject: [PATCH] =?UTF-8?q?test(admin):=20=E8=AE=A2=E9=98=85=E9=94=81?= =?UTF-8?q?=E5=AE=9A=E6=B2=BB=E7=90=86=E5=85=A5=E5=8F=A3=E5=BA=94=E5=8C=85?= =?UTF-8?q?=E5=90=AB=E7=BB=AD=E8=B4=B9=E7=BC=BA=E8=AE=A2=E9=98=85=E5=BF=AB?= =?UTF-8?q?=E6=8D=B7=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...dIncludeRenewalMissingSubscriptionTest.php | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexSubscriptionLockGovernanceLinksShouldIncludeRenewalMissingSubscriptionTest.php diff --git a/tests/Feature/AdminPlatformOrderIndexSubscriptionLockGovernanceLinksShouldIncludeRenewalMissingSubscriptionTest.php b/tests/Feature/AdminPlatformOrderIndexSubscriptionLockGovernanceLinksShouldIncludeRenewalMissingSubscriptionTest.php new file mode 100644 index 0000000..38502fc --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexSubscriptionLockGovernanceLinksShouldIncludeRenewalMissingSubscriptionTest.php @@ -0,0 +1,85 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_subscription_lock_governance_links_should_include_renewal_missing_subscription(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + + $plan = Plan::query()->create([ + 'code' => 'po_index_sub_lock_rms_plan', + 'name' => '平台订单列表订阅锁定治理入口(续费缺订阅)测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $sub = SiteSubscription::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'status' => 'active', + 'source' => 'manual', + 'subscription_no' => 'SS_SUB_LOCK_RMS_0001', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'amount' => 10, + 'starts_at' => now(), + 'ends_at' => now()->addMonth(), + ]); + + $res = $this->get('/admin/platform-orders?lead_id=12&merchant_id=' . $merchant->id . '&plan_id=' . $plan->id . '&site_subscription_id=' . $sub->id . '&keyword=abc&page=9&back=%2Fadmin%2Fplans&syncable_only=1'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + $matched = preg_match('/]+href="([^"]+)"[^>]*>\s*查看续费缺订阅(该订阅)\s*<\/a>/u', $html, $m); + $this->assertSame(1, $matched, '未找到订阅治理入口:查看续费缺订阅(该订阅)'); + + $url = $m[1] ?? ''; + $parts = parse_url($url); + parse_str($parts['query'] ?? '', $q); + + // 应保留上下文:merchant/plan/subscription/keyword/lead/back + $this->assertSame('12', (string) ($q['lead_id'] ?? '')); + $this->assertSame((string) $merchant->id, (string) ($q['merchant_id'] ?? '')); + $this->assertSame((string) $plan->id, (string) ($q['plan_id'] ?? '')); + $this->assertSame((string) $sub->id, (string) ($q['site_subscription_id'] ?? '')); + $this->assertSame('abc', (string) ($q['keyword'] ?? '')); + + // 注意:quick filter 会保留 back(safeBackForLinks),并清空 page + $this->assertSame('/admin/plans', (string) ($q['back'] ?? '')); + + // 并覆盖 renewal_missing_subscription + $this->assertSame('1', (string) ($q['renewal_missing_subscription'] ?? '')); + + // 不应继承工具型开关 + $this->assertArrayNotHasKey('syncable_only', $q); + $this->assertArrayNotHasKey('page', $q); + } +}