<?php

namespace Tests\Feature\Api\V1\FullSurface;

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

class ApiBatch15StudentSafetyIncidentEscalationContractTest extends FullSurfaceE2EContractCase
{

    public function test_batch15_safety_incident_escalation_routes_are_not_mutable_by_parents_or_students(): void
    {
        $routes = $this->apiRoutesContainingAny(['incident', 'violation', 'safety', 'alert', 'flag', 'dismissal', 'late', 'absence', 'attendance']);

        foreach (array_slice($routes, 0, 50) as $route) {
            $method = $this->primaryMethod($route);
            $uri = $route->uri();
            $payload = $this->payloadFor($method, $uri) + [
                'severity' => 'critical',
                'student_id' => $this->ids['studentId'],
                'resolved' => true,
                'resolved_by' => $this->admin->id,
                'notify_parent' => false,
                'suppress_alert' => true,
            ];

            foreach ([$this->parent, $this->studentUser] as $actor) {
                $response = $this->requestAs($actor, $method, $uri, $payload);
                $this->assertControlled($response, $method, $uri);
            }
        }
    }

}
