<?php

namespace Tests\Api;

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

class OldcustomerApiTest extends TestCase
{
    use MakeOldcustomerTrait, ApiTestTrait, WithoutMiddleware, DatabaseTransactions;

    /**
     * @test
     */
    public function testCreateOldcustomer()
    {
        $oldcustomer = $this->fakeOldcustomerData();
        $this->json('POST', '/api/v1/oldcustomers', $oldcustomer);

        $this->assertApiResponse($oldcustomer);
    }

    /**
     * @test
     */
    public function testReadOldcustomer()
    {
        $oldcustomer = $this->makeOldcustomer();
        $this->json('GET', '/api/v1/oldcustomers/'.$oldcustomer->id);

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

    /**
     * @test
     */
    public function testUpdateOldcustomer()
    {
        $oldcustomer = $this->makeOldcustomer();
        $editedOldcustomer = $this->fakeOldcustomerData();

        $this->json('PUT', '/api/v1/oldcustomers/'.$oldcustomer->id, $editedOldcustomer);

        $this->assertApiResponse($editedOldcustomer);
    }

    /**
     * @test
     */
    public function testDeleteOldcustomer()
    {
        $oldcustomer = $this->makeOldcustomer();
        $this->json('DELETE', '/api/v1/oldcustomers/'.$oldcustomer->id);

        $this->assertApiSuccess();
        $this->json('GET', '/api/v1/oldcustomers/'.$oldcustomer->id);

        $this->assertResponseStatus(404);
    }
}
