<?php

namespace Tests\Unit;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use App\User;
use App\Company;
use Artisan;

class WarehouseTest extends TestCase
{
    protected $company;
    protected $user;

    public function setUp()
    {
        parent::setUp();
        Artisan::call('db:seed');

        $this->user = factory(User::class)->create();
        $this->company = $this->user->each(function ($u) {
            factory(Company::class)->create([
                'user_id' => $u->id,
            ]);
        });
    }

    public function testPost()
    { 
        $response = $this->actingAs($this->user)
            ->postJson('/api/warehouse', [
 
            'address'=> 'Testing',
            'city'=>'Testing ',
            'zip'=>' Testing',
            'state' =>'Testing',
            'contact_person' =>'Testing ',
            'contact_person_no' =>'12345 ',
            'branch'=>'Testing ',
            'country' =>' Testing',
            'com_id' =>'99'
 
        ]);

        $response->assertStatus(201); 
      
    }

   public function testUpdate()
   {

        $response = $this->actingAs($this->user)
            ->patchJson('/api/warehouse', [
 
            'address' => 'Changed Testing',
            'city' => 'Testing ',
            'zip' => ' Testing',
            'state' => 'Testing',
            'contact_person' => 'Testing ',
            'contact_person_no' => '12345 ',
            'branch' => 'Testing ',
            'country' => ' Testing',
            'com_id' => '99'
 
        ]);

        $response->assertStatus(201); 
       
   }

    public function testDelete()
    {   
         $this->actingAs($this->user)
            ->json('DELETE', '/api/so/99');

         $response->assertStatus(204);
    }

}
