From ee46915194d01124c3b0e567c0e47b2e7cf402f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sun, 15 Mar 2026 06:47:48 +0000 Subject: [PATCH] test: renewal_missing_subscription filter should work --- ...issingSubscriptionFilterShouldWorkTest.php | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderRenewalMissingSubscriptionFilterShouldWorkTest.php diff --git a/tests/Feature/AdminPlatformOrderRenewalMissingSubscriptionFilterShouldWorkTest.php b/tests/Feature/AdminPlatformOrderRenewalMissingSubscriptionFilterShouldWorkTest.php new file mode 100644 index 0000000..4f970f0 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderRenewalMissingSubscriptionFilterShouldWorkTest.php @@ -0,0 +1,119 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_renewal_missing_subscription_filter_should_only_show_renewal_orders_without_subscription(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + + $plan = Plan::query()->create([ + 'code' => 'po_renewal_missing_sub_filter_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_PO_FILTER_SUB_0001', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'amount' => 10, + 'starts_at' => now()->subDays(10), + 'ends_at' => now()->addDays(20), + 'snapshot' => [], + 'meta' => [], + ]); + + $shouldShow = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_RENEWAL_MISSING_SUB_SHOW_0001', + 'order_type' => 'renewal', + 'site_subscription_id' => null, + '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()->subMinutes(10), + 'meta' => [], + ]); + + $renewalWithSubShouldNotShow = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'site_subscription_id' => $sub->id, + 'order_no' => 'PO_RENEWAL_WITH_SUB_HIDE_0002', + 'order_type' => 'renewal', + '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()->subMinutes(9), + 'meta' => [], + ]); + + $newPurchaseWithoutSubShouldNotShow = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_NEW_NO_SUB_HIDE_0003', + 'order_type' => 'new_purchase', + 'site_subscription_id' => null, + '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()->subMinutes(8), + 'meta' => [], + ]); + + $this->get('/admin/platform-orders?renewal_missing_subscription=1') + ->assertOk() + ->assertSee($shouldShow->order_no) + ->assertDontSee($renewalWithSubShouldNotShow->order_no) + ->assertDontSee($newPurchaseWithoutSubShouldNotShow->order_no); + } +}