<?php

namespace Tests\Feature\Api\V1\FullSurface;

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


class ApiBatch17MultiGuardBoundaryContractTest extends FullSurfaceE2EContractCase
{
    public function test_api_guard_boundaries_are_not_crossed_by_session_or_web_identity(): void
    {
        $routes = $this->apiRoutesContainingAny(['admin', 'users', 'finance', 'settings', 'school-years', 'inventory']);

        foreach (array_slice($routes, 0, 70) as $route) {
            $method = $this->primaryMethod($route);
            $uri = $route->uri();

            $this->actingAs($this->parent, 'web');
            $response = $this->json($method, $this->materializePath($uri), $this->payloadFor($method, $uri), [
                'Accept' => 'application/json',
                'X-Requested-With' => 'XMLHttpRequest',
            ]);

            $this->assertControlled($response, $method, $uri);
            $this->assertNotEquals(500, $response->getStatusCode(), $method.' '.$uri.' crashed under web guard identity.');
        }
    }
}
