From 5a060131f68deb017790a03bf9a8fa9aac764cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 11 Mar 2026 00:04:25 +0000 Subject: [PATCH] =?UTF-8?q?test(platform-orders):=20=E6=B8=85=E7=90=86?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=A0=87=E8=AE=B0=20filtered=20=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E8=A1=A5=E5=85=85=20refund=5Fstatus=20=E5=8F=A3?= =?UTF-8?q?=E5=BE=84=E6=B5=8B=E8=AF=95=E6=8A=A4=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...atformOrderClearSyncErrorsFilteredTest.php | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/tests/Feature/AdminPlatformOrderClearSyncErrorsFilteredTest.php b/tests/Feature/AdminPlatformOrderClearSyncErrorsFilteredTest.php index a20c305..6179df5 100644 --- a/tests/Feature/AdminPlatformOrderClearSyncErrorsFilteredTest.php +++ b/tests/Feature/AdminPlatformOrderClearSyncErrorsFilteredTest.php @@ -84,10 +84,38 @@ class AdminPlatformOrderClearSyncErrorsFilteredTest extends TestCase ], ]); - // 仅清理“status=pending”范围内的失败标记:应该只清掉 failedA + $failedRefunded = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_CLEAR_ERR_F_REFUNDED', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'paid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 1, + 'paid_amount' => 1, + 'placed_at' => now(), + 'meta' => [ + 'refund_summary' => [ + 'count' => 1, + 'total_amount' => 0.50, + ], + 'subscription_activation_error' => [ + 'message' => '模拟失败REFUNDED', + 'at' => now()->toDateTimeString(), + 'admin_id' => 1, + ], + ], + ]); + + // 仅清理“status=pending + refund_status=none”范围内的失败标记:应该只清掉 failedA(不应清掉 failedRefunded) $this->post('/admin/platform-orders/clear-sync-errors', [ 'scope' => 'filtered', 'status' => 'pending', + 'refund_status' => 'none', ])->assertRedirect(); // 增加一条带 subscription_id 的失败订单,用于验证 site_subscription_id 精确过滤生效 @@ -141,11 +169,15 @@ class AdminPlatformOrderClearSyncErrorsFilteredTest extends TestCase $failedA->refresh(); $failedB->refresh(); + $failedRefunded->refresh(); $this->assertEmpty(data_get($failedA->meta, 'subscription_activation_error')); $this->assertNotEmpty(data_get($failedA->meta, 'audit.0.action')); $this->assertSame('clear_sync_error', data_get($failedA->meta, 'audit.0.action')); $this->assertNotEmpty(data_get($failedB->meta, 'subscription_activation_error.message')); + + // 有退款的失败订单不应被 refund_status=none 的清理动作误命中 + $this->assertNotEmpty(data_get($failedRefunded->meta, 'subscription_activation_error.message')); } }