<?php

namespace Tests\Unit;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Storage;
use Artisan;
use App\User;
use App\Company;
use App\Deliveryinfo;

class DeliveryinfoTest 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,
            ]);
        });
    }

    // TODO : those test is wrong, please redo later.
    // REDO the test 

    public function testPost()
    {

        $response = $this->actingAs($this->user) 
        ->postJson('/api/deliveryinfo', [

            'branch' => 'Testing', 
            'deli_info' => 'Testing',
            'address' => 'Testing',
            'city' => 'Testing',
            'postcode' => '12345',
            'state' => 'Testing',
            'country' => 'Testing',
            'contact_person' => 'Testing',
            'contact_person_no' => '12345'
                                    
        ]);
                     
          $response->assertStatus(201);
    }


     public function testPut()
    {

        $response = $this->actingAs($this->user) 
        ->patchJson('/api/deliveryinfo', [

        'branch' => 'ChangedTesting', 
        'deli_info' => 'Testing',
        'address' => 'Testing',
        'city' => 'Testing',
        'postcode' => '12345',
        'state' => 'Testing',
        'country' => 'Testing',
        'contact_person' => 'Testing',
        'contact_person_no' => '12345'
                                
        ]);
                     
          $response->assertStatus(200);
    }

    public function testDELETE()
    {
         $response = $this->json('DELETE', '/api/deliveryinfo');

         $response->assertStatus(204);
    }
 
}
