From 62e045134fd10a7205680e346f9362c84d45312b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 14:03:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95:=20=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E6=B2=BB=E7=90=86=E5=85=A5=E5=8F=A3=E5=90=8C=E6=AD=A5=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E9=93=BE=E6=8E=A5=E6=B8=85=E7=90=86BMPA=E5=BC=80?= =?UTF-8?q?=E5=85=B3=E6=8A=A4=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...vernanceLinkShouldClearBmpaFiltersTest.php | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexSubscriptionGovernanceLinkShouldClearBmpaFiltersTest.php diff --git a/tests/Feature/AdminPlatformOrderIndexSubscriptionGovernanceLinkShouldClearBmpaFiltersTest.php b/tests/Feature/AdminPlatformOrderIndexSubscriptionGovernanceLinkShouldClearBmpaFiltersTest.php new file mode 100644 index 0000000..c57cf55 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexSubscriptionGovernanceLinkShouldClearBmpaFiltersTest.php @@ -0,0 +1,76 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_subscription_governance_sync_failed_link_should_clear_bmpa_filters(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_idx_sub_gov_clear_bmpa_plan', + 'name' => '平台订单列表订阅治理入口清理BMPA开关测试套餐', + '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' => 'activated', + 'source' => 'manual', + 'subscription_no' => 'SUB_PO_IDX_GOV_CLEAR_BMPA_0001', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'amount' => 10, + 'starts_at' => now()->subDay(), + 'ends_at' => now()->addMonth(), + 'activated_at' => now()->subDay(), + ]); + + // 从订阅锁定 + BMPA 失败上下文进入 + $res = $this->get('/admin/platform-orders?site_subscription_id=' . $sub->id . '&bmpa_failed_only=1&sync_status=failed'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + // 定位订阅治理入口:查看同步失败(该订阅) + $this->assertMatchesRegularExpression('/href="([^"]+)"[^>]*>查看同步失败(该订阅)<\/a>/', $html); + preg_match('/href="([^"]+)"[^>]*>查看同步失败(该订阅)<\/a>/', $html, $m); + $href = html_entity_decode($m[1] ?? ''); + + $query = parse_url($href, PHP_URL_QUERY) ?: ''; + parse_str($query, $q); + + $this->assertSame('failed', (string) ($q['sync_status'] ?? '')); + $this->assertSame((string) $sub->id, (string) ($q['site_subscription_id'] ?? '')); + + $this->assertArrayNotHasKey('bmpa_failed_only', $q); + $this->assertArrayNotHasKey('bmpa_error_keyword', $q); + } +}