<?php

namespace Tests\Feature\Api\V1\FullSurface;

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

class ApiBatch15FeatureFlagExperimentAndRolloutContractTest extends FullSurfaceE2EContractCase
{

    public function test_batch15_feature_flag_and_rollout_routes_reject_low_privilege_override_payloads(): void
    {
        $routes = $this->apiRoutesContainingAny(['feature', 'flag', 'experiment', 'rollout', 'settings', 'configuration']);

        foreach (array_slice($routes, 0, 35) as $route) {
            $method = $this->primaryMethod($route);
            $uri = $route->uri();
            $payload = $this->payloadFor($method, $uri) + [
                'feature' => 'all_admin_features',
                'enabled' => true,
                'rollout' => 100,
                'audience' => 'all',
                'actor_id' => $this->parent->id,
                'bypass_permissions' => true,
                'expires_at' => '2099-01-01',
            ];

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

}
