From 4530957daef9fc86c693b4e8d5aa8dccd0abe96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sat, 14 Mar 2026 14:53:25 +0000 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E8=AE=A2=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=EF=BC=9A=E8=A1=A5=E9=BD=90=E5=A4=B1=E8=B4=A5=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0=E8=BF=87=E9=95=BF=E4=B8=8D=E7=94=9F=E6=88=90keyword?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E7=9A=84=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 --- ...ReasonLongDoesNotRenderKeywordLinkTest.php | 75 ++++++++++++++++++ ...ReasonLongDoesNotRenderKeywordLinkTest.php | 76 +++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderBmpaFailedReasonLongDoesNotRenderKeywordLinkTest.php create mode 100644 tests/Feature/AdminPlatformOrderSyncFailedReasonLongDoesNotRenderKeywordLinkTest.php diff --git a/tests/Feature/AdminPlatformOrderBmpaFailedReasonLongDoesNotRenderKeywordLinkTest.php b/tests/Feature/AdminPlatformOrderBmpaFailedReasonLongDoesNotRenderKeywordLinkTest.php new file mode 100644 index 0000000..45fc373 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderBmpaFailedReasonLongDoesNotRenderKeywordLinkTest.php @@ -0,0 +1,75 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_platform_orders_page_long_bmpa_reason_should_not_render_keyword_link(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'bmpa_reason_long_guard_plan', + 'name' => 'BMPA失败原因过长链接护栏测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + // 需要超过页面阈值(默认 config 为 200),这里用 260 触发“原因过长”分支 + $longReason = str_repeat('错', 260); + + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_BMPA_LONG_REASON_0001', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'unpaid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 0, + 'placed_at' => now(), + 'meta' => [ + 'batch_mark_paid_and_activate_error' => [ + 'message' => $longReason, + 'at' => now()->toDateTimeString(), + 'admin_id' => 1, + ], + ], + ]); + + $res = $this->get('/admin/platform-orders'); + $res->assertOk(); + + // 原因过长时应出现提示,但不生成包含 bmpa_error_keyword 的链接 + $res->assertSee('批量标记支付并生效失败原因 TOP5'); + $res->assertSee('原因过长,请复制到筛选框', false); + $res->assertDontSee('bmpa_error_keyword=' . urlencode($longReason), false); + } +} diff --git a/tests/Feature/AdminPlatformOrderSyncFailedReasonLongDoesNotRenderKeywordLinkTest.php b/tests/Feature/AdminPlatformOrderSyncFailedReasonLongDoesNotRenderKeywordLinkTest.php new file mode 100644 index 0000000..e805b8b --- /dev/null +++ b/tests/Feature/AdminPlatformOrderSyncFailedReasonLongDoesNotRenderKeywordLinkTest.php @@ -0,0 +1,76 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_platform_orders_page_long_sync_reason_should_not_render_keyword_link(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'sync_reason_long_guard_plan', + 'name' => '同步失败原因过长链接护栏测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + // 需要超过页面阈值(默认 config 为 200),这里用 260 触发“原因过长”分支 + $longReason = str_repeat('E', 260); + + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_SYNC_LONG_REASON_0001', + 'order_type' => 'new_purchase', + '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' => [ + 'subscription_activation_error' => [ + 'message' => $longReason, + 'at' => now()->toDateTimeString(), + 'admin_id' => 1, + ], + ], + ]); + + $res = $this->get('/admin/platform-orders'); + $res->assertOk(); + + $res->assertSee('同步失败原因 TOP5'); + $res->assertSee('原因过长,请复制到筛选框', false); + $res->assertDontSee('sync_error_keyword=' . urlencode($longReason), false); + } +}