<?php

namespace Tests\Feature\Api\V1\FullSurface;

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

class ApiBatch15DomainEventOutboxAndNotificationConsistencyContractTest extends FullSurfaceE2EContractCase
{

    public function test_batch15_event_outbox_and_notification_trigger_routes_reject_forged_event_metadata(): void
    {
        $routes = $this->apiRoutesContainingAny(['event', 'outbox', 'notification', 'broadcast', 'message', 'email', 'whatsapp', 'webhook']);

        foreach (array_slice($routes, 0, 45) as $route) {
            $method = $this->primaryMethod($route);
            $uri = $route->uri();
            $payload = $this->payloadFor($method, $uri) + [
                'event_id' => 'evt_batch15_replay',
                'event_type' => 'UserPromotedToAdministrator',
                'aggregate_type' => 'school',
                'aggregate_id' => '*',
                'actor_id' => $this->admin->id,
                'delivered_at' => '2099-01-01T00:00:00Z',
                'signature' => 'forged-signature',
            ];

            $response = $this->requestAs($this->teacher, $method, $uri, $payload);
            $this->assertControlled($response, $method, $uri);
        }
    }

}
