<?php

namespace Tests\Feature;

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

class AdminPlatformOrderBatchActivateSubscriptionsShouldBlockWhenRenewalMissingSubscriptionTest 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_activate_should_block_when_renewal_missing_subscription_present(): void
    {
        $this->loginAsPlatformAdmin();

        $res = $this->post('/admin/platform-orders/batch-activate-subscriptions', [
            'scope' => 'filtered',
            'renewal_missing_subscription' => '1',
            // syncable_only 即使传了，也应被治理集合优先阻断
            'syncable_only' => '1',
            'limit' => 50,
        ]);

        $res->assertRedirect();
        $res->assertSessionHas('warning');
    }
}
