<?php

namespace Tests\Feature\Api\V1\FullSurface;

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


class ApiBatch17InventoryAssetCustodyContractTest extends FullSurfaceE2EContractCase
{
    public function test_inventory_asset_custody_transfers_and_disposal_are_not_client_authorized(): void
    {
        $routes = $this->apiRoutesContainingAny(['inventory', 'asset', 'custody', 'supplier', 'supply', 'purchase', 'receiving']);
        $payload = [
            'item_id' => $this->ids['itemId'],
            'supplier_id' => $this->ids['supplierId'],
            'quantity' => -50,
            'custodian_user_id' => $this->studentUser->id,
            'assigned_to' => $this->studentUser->id,
            'disposed' => true,
            'write_off' => true,
            'approved_by' => $this->admin->id,
            'skip_stock_check' => true,
        ];

        foreach (array_slice($routes, 0, 80) as $route) {
            $method = $this->primaryMethod($route);
            if ($method === 'GET') {
                continue;
            }

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