<?php

namespace App\Tests\Application\Cotisation;

use App\Tests\Application\OtWebTestCase;

class CotisationTest extends OtWebTestCase
{
    public function testGetCotisationId(): void
    {
        $this->logger->info("\033[1;34mStarting test... Get a cotisation by id as ad admin\033[0m");
        $this->loginAs($this->user);
        $this->get('/api/cotisations/1');
        $this->assertResponseStatusCodeSame(200);
        $this->assertJsonContains([
            '@context' => '/api/contexts/Cotisation',
            '@id' => '/api/cotisations/1',
            '@type' => 'Cotisation',
            'organizationId' => 1,
            'alertState' => 'ADVERTISINGINSURANCE',
            'cotisationYear' => 2024,
        ]);
        $this->logger->info("\033[1;32mTest 'Get a cotisation by id as ad admin' succeed\033[0m");

        $this->logger->info("\033[1;34mStarting test... Get a cotisation by id as an non admin\033[0m");
        $this->loginAsStudent($this->user);
        $this->get('/api/cotisations/1');
        $this->assertResponseStatusCodeSame(403);
        $this->logger->info("\033[1;32mTest 'Get a cotisation by id as an non admin' succeed\033[0m");

        $this->logger->info("\033[1;34mStarting test... Put a cotisation by id as an admin\033[0m");
        $this->loginAs($this->user);
        $this->put('/api/cotisations/1', [
            'alertState' => 'ADVERTISINGINSURANCE',
            'cotisationYear' => 2024,
        ]);
        $this->assertResponseStatusCodeSame(405);
        $this->logger->info("\033[1;32mTest 'Put a cotisation by id as an admin' succeed\033[0m");

        $this->logger->info("\033[1;34mStarting test... Delete a cotisation by id as an admin\033[0m");
        $this->loginAs($this->user);
        $this->delete('/api/cotisations/1');
        $this->assertResponseStatusCodeSame(405);
        $this->logger->info("\033[1;32mTest 'Delete a cotisation by id as an admin' succeed\033[0m");
    }
}
