diff --git a/tests/Feature/AdminPlatformOrderBatchMarkActivatedTest.php b/tests/Feature/AdminPlatformOrderBatchMarkActivatedTest.php index fe81d00..290a5e8 100644 --- a/tests/Feature/AdminPlatformOrderBatchMarkActivatedTest.php +++ b/tests/Feature/AdminPlatformOrderBatchMarkActivatedTest.php @@ -129,6 +129,55 @@ class AdminPlatformOrderBatchMarkActivatedTest extends TestCase ])->assertRedirect(); } + public function test_batch_mark_activated_requires_sync_status_unsynced_in_filtered_scope(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'batch_mark_activated_sync_status_guard_plan', + 'name' => '批量生效 sync_status 安全阀测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $o1 = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_BATCH_MARK_SYNC_STATUS_GUARD_0001', + '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' => 10, + 'paid_amount' => 10, + 'placed_at' => now()->subMinutes(10), + 'paid_at' => now()->subMinutes(5), + 'meta' => [], + ]); + + // 故意不传 sync_status=unsynced(模拟旧入口/误操作) + $this->post('/admin/platform-orders/batch-mark-activated', [ + 'scope' => 'filtered', + 'payment_status' => 'paid', + 'status' => 'pending', + 'sync_status' => '', + 'limit' => 50, + ]) + ->assertRedirect() + ->assertSessionHas('warning'); + + $o1->refresh(); + $this->assertSame('pending', $o1->status); + } + public function test_guest_cannot_batch_mark_activated(): void { $this->seed();