<?php

namespace Tests\Api;

use Tests\ApiTestTrait;
use Tests\TestCase;
use Tests\Traits\MakeProductionTeamTrait;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class ProductionTeamApiTest extends TestCase
{
    use MakeProductionTeamTrait, ApiTestTrait, WithoutMiddleware, DatabaseTransactions;

    /**
     * @test
     */
    public function testCreateProductionTeam()
    {
        $productionTeam = $this->fakeProductionTeamData();
        $this->json('POST', '/api/v1/production-teams', $productionTeam);

        $this->assertApiResponse($productionTeam);
    }

    /**
     * @test
     */
    public function testReadProductionTeam()
    {
        $productionTeam = $this->makeProductionTeam();
        $this->json('GET', '/api/v1/production-teams/'.$productionTeam->id);

        $this->assertApiResponse($productionTeam->toArray());
    }

    /**
     * @test
     */
    public function testUpdateProductionTeam()
    {
        $productionTeam = $this->makeProductionTeam();
        $editedProductionTeam = $this->fakeProductionTeamData();

        $this->json('PUT', '/api/v1/production-teams/'.$productionTeam->id, $editedProductionTeam);

        $this->assertApiResponse($editedProductionTeam);
    }

    /**
     * @test
     */
    public function testDeleteProductionTeam()
    {
        $productionTeam = $this->makeProductionTeam();
        $this->json('DELETE', '/api/v1/production-teams/'.$productionTeam->id);

        $this->assertApiSuccess();
        $this->json('GET', '/api/v1/production-teams/'.$productionTeam->id);

        $this->assertResponseStatus(404);
    }
}
