<?php

namespace Tests\Feature\Api\V1\FullSurface;

use Tests\Feature\Api\V1\FullSurface\Support\FullSurfaceE2EContractCase;

class ApiAccountStatusLifecycleContractTest extends FullSurfaceE2EContractCase
{
    public function test_suspended_disabled_and_pending_status_values_do_not_gain_access_through_profile_or_dashboard_routes(): void
    {
        $routes = array_slice($this->apiRoutesContainingAny(['auth/me', 'frontend', 'dashboard', 'profile', 'preferences', 'notifications']), 0, 80);
        $statuses = ['suspended', 'disabled', 'inactive', 'pending', 'blocked'];

        foreach ($statuses as $status) {
            $actor = $this->createApiUserWithRole('parent', ['status' => $status]);

            foreach ($routes as $route) {
                $method = $this->primaryMethod($route);
                if ($method !== 'GET') {
                    continue;
                }

                $uri = $route->uri();
                $response = $this->requestAs($actor, 'GET', $uri);

                $this->assertControlled($response, 'GET', $uri);
                $this->assertNoServerError($response, 'account status ' . $status . ' at GET ' . $uri);
            }
        }
    }
}
