<?php

namespace Tests\Api;

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

class QaLeadApiTest extends TestCase
{
    use MakeQaLeadTrait, ApiTestTrait, WithoutMiddleware, DatabaseTransactions;

    /**
     * @test
     */
    public function testCreateQaLead()
    {
        $qaLead = $this->fakeQaLeadData();
        $this->json('POST', '/api/v1/qa-leads', $qaLead);

        $this->assertApiResponse($qaLead);
    }

    /**
     * @test
     */
    public function testReadQaLead()
    {
        $qaLead = $this->makeQaLead();
        $this->json('GET', '/api/v1/qa-leads/'.$qaLead->id);

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

    /**
     * @test
     */
    public function testUpdateQaLead()
    {
        $qaLead = $this->makeQaLead();
        $editedQaLead = $this->fakeQaLeadData();

        $this->json('PUT', '/api/v1/qa-leads/'.$qaLead->id, $editedQaLead);

        $this->assertApiResponse($editedQaLead);
    }

    /**
     * @test
     */
    public function testDeleteQaLead()
    {
        $qaLead = $this->makeQaLead();
        $this->json('DELETE', '/api/v1/qa-leads/'.$qaLead->id);

        $this->assertApiSuccess();
        $this->json('GET', '/api/v1/qa-leads/'.$qaLead->id);

        $this->assertResponseStatus(404);
    }
}
