From 633b9c9cbcc967f3629e8aee015de3809cde140a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Tue, 17 Mar 2026 23:52:38 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=B9=B3=E5=8F=B0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=A1=8C=E7=BA=A7=E5=90=8C=E6=AD=A5=E8=AE=A2?= =?UTF-8?q?=E9=98=85=E6=8C=89=E9=92=AE=E5=9C=A8=E7=BB=AD=E8=B4=B9=E7=BC=BA?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E6=97=B6=E5=BA=94=E7=A6=81=E7=94=A8=E5=B9=B6?= =?UTF-8?q?=E5=BC=95=E5=AF=BC=E5=85=B3=E8=81=94=E8=AE=A2=E9=98=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ableWhenRenewalMissingSubscriptionTest.php | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexRowActivateSubscriptionButtonShouldDisableWhenRenewalMissingSubscriptionTest.php diff --git a/tests/Feature/AdminPlatformOrderIndexRowActivateSubscriptionButtonShouldDisableWhenRenewalMissingSubscriptionTest.php b/tests/Feature/AdminPlatformOrderIndexRowActivateSubscriptionButtonShouldDisableWhenRenewalMissingSubscriptionTest.php new file mode 100644 index 0000000..92a38ef --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexRowActivateSubscriptionButtonShouldDisableWhenRenewalMissingSubscriptionTest.php @@ -0,0 +1,75 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_row_activate_subscription_button_should_be_disabled_when_renewal_missing_subscription(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_index_row_sync_disable_renewal_missing_sub_plan', + 'name' => '平台订单列表行级同步订阅禁用(续费缺订阅)测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 30, + 'list_price' => 30, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + // 构造:续费单已支付已生效,但缺订阅(脏数据) + $order = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_INDEX_ROW_SYNC_DISABLE_RENEW_MISS_SUB_0001', + 'order_type' => 'renewal', + 'site_subscription_id' => null, + 'status' => 'activated', + 'payment_status' => 'paid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 30, + 'paid_amount' => 30, + 'placed_at' => now(), + 'paid_at' => now(), + 'activated_at' => now(), + 'meta' => [], + ]); + + $res = $this->get('/admin/platform-orders'); + $res->assertOk(); + + $html = (string) $res->getContent(); + $this->assertStringContainsString($order->order_no, $html); + + // 断言:该订单所在行的“同步订阅”按钮应被禁用(避免运营在列表页误触) + $pattern = '#/admin/platform-orders/' . $order->id . '/activate-subscription.*?]*disabled#s'; + $this->assertMatchesRegularExpression($pattern, $html); + + // 并且应提供最短治理入口(续费缺订阅:去关联订阅) + $this->assertStringContainsString('#relation-subscription', $html); + } +}