From ebc0bd8ce2b7a51d18b2b781510978b059296054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sun, 15 Mar 2026 05:57:53 +0000 Subject: [PATCH] tests: syncable_only filter excludes renewal missing subscription --- ...dExcludeRenewalMissingSubscriptionTest.php | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderSyncableFilterShouldExcludeRenewalMissingSubscriptionTest.php diff --git a/tests/Feature/AdminPlatformOrderSyncableFilterShouldExcludeRenewalMissingSubscriptionTest.php b/tests/Feature/AdminPlatformOrderSyncableFilterShouldExcludeRenewalMissingSubscriptionTest.php new file mode 100644 index 0000000..ab0d89e --- /dev/null +++ b/tests/Feature/AdminPlatformOrderSyncableFilterShouldExcludeRenewalMissingSubscriptionTest.php @@ -0,0 +1,84 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_syncable_only_filter_should_exclude_renewal_orders_missing_subscription(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_syncable_filter_exclude_renewal_missing_sub_plan', + 'name' => 'syncable_only 筛选排除续费无订阅测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $bad = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_SYNCABLE_FILTER_BAD_RENEW_NO_SUB_0001', + 'order_type' => 'renewal', + '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()->subMinutes(10), + 'paid_at' => now()->subMinutes(9), + 'activated_at' => now()->subMinutes(8), + 'meta' => [], + ]); + + $good = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_SYNCABLE_FILTER_OK_NEW_0002', + '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()->subMinutes(7), + 'paid_at' => now()->subMinutes(6), + 'activated_at' => now()->subMinutes(5), + 'meta' => [], + ]); + + $this->get('/admin/platform-orders?syncable_only=1') + ->assertOk() + ->assertSee($good->order_no) + ->assertDontSee($bad->order_no); + } +}