<?php

namespace Tests\Api;

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

class LeadStatusApiTest extends TestCase
{
    use MakeLeadStatusTrait, ApiTestTrait, WithoutMiddleware, DatabaseTransactions;

    /**
     * @test
     */
    public function testCreateLeadStatus()
    {
        $leadStatus = $this->fakeLeadStatusData();
        $this->json('POST', '/api/v1/lead-statuses', $leadStatus);

        $this->assertApiResponse($leadStatus);
    }

    /**
     * @test
     */
    public function testReadLeadStatus()
    {
        $leadStatus = $this->makeLeadStatus();
        $this->json('GET', '/api/v1/lead-statuses/'.$leadStatus->id);

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

    /**
     * @test
     */
    public function testUpdateLeadStatus()
    {
        $leadStatus = $this->makeLeadStatus();
        $editedLeadStatus = $this->fakeLeadStatusData();

        $this->json('PUT', '/api/v1/lead-statuses/'.$leadStatus->id, $editedLeadStatus);

        $this->assertApiResponse($editedLeadStatus);
    }

    /**
     * @test
     */
    public function testDeleteLeadStatus()
    {
        $leadStatus = $this->makeLeadStatus();
        $this->json('DELETE', '/api/v1/lead-statuses/'.$leadStatus->id);

        $this->assertApiSuccess();
        $this->json('GET', '/api/v1/lead-statuses/'.$leadStatus->id);

        $this->assertResponseStatus(404);
    }
}
