Files
izyim-api/tests/Unit/WarehouseTest.php
T
Zain Fauzan Rofie Azizi 70cc220337 rename test
2018-06-29 11:04:37 +08:00

83 lines
1.8 KiB
PHP

<?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);
}
}