<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class AdminPlatformOrderBatchMarkActivatedShouldBlockWhenReceiptStatusNoneTest extends TestCase
{
    use RefreshDatabase;

    protected function loginAsPlatformAdmin(): void
    {
        $this->seed();

        $this->post('/admin/login', [
            'email' => 'platform.admin@demo.local',
            'password' => 'Platform@123456',
        ])->assertRedirect('/admin');
    }

    public function test_batch_mark_activated_should_block_when_receipt_status_none_is_set(): void
    {
        $this->loginAsPlatformAdmin();

        $res = $this->post('/admin/platform-orders/batch-mark-activated', [
            'scope' => 'filtered',
            'payment_status' => 'paid',
            'status' => 'pending',
            'sync_status' => 'unsynced',
            'receipt_status' => 'none',
            'limit' => 50,
        ]);

        $res->assertRedirect();
        $res->assertSessionHas('warning');
        $this->assertStringContainsString('无回执（广义）', (string) session('warning'));
    }
}
