<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Role;
use Artisan;
use App\User;
use App\Rate;

class RateTest extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */

    protected $user;
    protected $rate;

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

        $this->user = factory(User::class)->create();
        $this->rate = factory(Rate::class)->create();
        $this->user->attachRole(Role::Where('name','admin')->first());
    }

    public function testStore(){
    	$response =
    	$this->actingAs($this->user)
    	  ->postJson('/api/update-rate/',[
    	      'x1_cash' => '1.2',
    	      'x1_cheque' => '1.2',
    	      'x1_ba' => '1.2',
    	      'x2_cash' => '1.2',
    	      'x2_cheque' => '1.2',
    	      'x2_ba' => '1.2'
    	  ])
    	  ->assertStatus(201);
	}
	
    public function testUpdate(){
    	$response =
    	$this->actingAs($this->user)
    	  ->json('PUT','/api/update-rate/' . $this->rate->id,[
    	      'x1_cash' => '1.2',
    	      'x1_cheque' => '1.2',
    	      'x1_ba' => '1.2',
    	      'x2_cash' => '1.2',
    	      'x2_cheque' => '1.2',
    	      'x2_ba' => '1.2'
    	  ])
    	  ->assertStatus(200);
	}
	
    public function testShowRate(){
	    $response = $this->json('GET', '/api/rate');
    	$response
        	->assertStatus(200);
    }

}
