<?php

namespace Tests\Feature\Api\V1\FullSurface;

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

class ApiBatch16ImportPreviewCommitSeparationContractTest extends FullSurfaceE2EContractCase
{
    public function test_batch16_import_preview_payloads_cannot_force_commit_or_skip_validation(): void
    {
        $routes = $this->apiRoutesContainingAny(['import', 'upload', 'preview', 'commit', 'csv', 'template', 'bulk']);

        foreach (array_slice($routes, 0, 45) as $route) {
            $method = $this->primaryMethod($route);
            $uri = $route->uri();
            $response = $this->requestAs($this->actorFor($uri), $method, $uri, $this->payloadFor($method, $uri) + [
                'preview' => true,
                'commit' => true,
                'skip_validation' => true,
                'ignore_errors' => true,
                'rows' => [
                    ['email' => 'bad', 'student_id' => 999999, 'amount' => -1],
                    ['email' => '=cmd|\' /C calc\'!A0', 'student_id' => $this->ids['studentId']],
                ],
            ]);

            $this->assertControlled($response, $method, $uri);
            $this->assertStringNotContainsString('maatwebsite', strtolower($response->getContent()));
        }
    }
}
