mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 20:34:08 +00:00
69 lines
1.7 KiB
PHP
69 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use Tests\TestCase;
|
|
use Illuminate\Foundation\Testing\WithFaker;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use App\User;
|
|
use App\SettingSupplier;
|
|
use App\Role;
|
|
use Artisan;
|
|
|
|
class SettingSupplierTest extends TestCase
|
|
{
|
|
protected $user;
|
|
protected $settingSupplier;
|
|
|
|
public function setUp(){
|
|
parent::setUp();
|
|
Artisan::call('db:seed');
|
|
|
|
$this->user = factory(User::class)->create();
|
|
$this->settingSupplier = factory(SettingSupplier::class)->create();
|
|
$this->user->attachRole(Role::Where('name','admin')->first());
|
|
}
|
|
|
|
public function testStore(){
|
|
$this->actingAs($this->user)
|
|
->postJson('api/setting-supplier',[
|
|
'company_name' => "CompanyABC",
|
|
'gst_no' => "123321",
|
|
'supplier_reg_no' => "12332123",
|
|
'bank_name' => "maybank",
|
|
'acc_no' => "1231522334"
|
|
])
|
|
->assertStatus(201);
|
|
|
|
$this->assertDatabaseHas('setting_suppliers', [
|
|
'acc_no' => '1231522334'
|
|
]);
|
|
}
|
|
|
|
public function testUpdate(){
|
|
$this->actingAs($this->user)
|
|
->json('PUT','api/setting-supplier/' . $this->settingSupplier->id,[
|
|
'company_name' => "CompanyDDEDED",
|
|
'gst_no' => "gstgstgstgst",
|
|
'supplier_reg_no' => "ABC12332123",
|
|
'bank_name' => "Cimb bank",
|
|
'acc_no' => "7030303030"
|
|
])
|
|
->assertStatus(200);
|
|
}
|
|
|
|
public function testDelete(){
|
|
$id = $this->settingSupplier->id;
|
|
$this->actingAs($this->user)
|
|
->json('DELETE','api/setting-supplier/' . $this->settingSupplier->id,[
|
|
'id' => $this->settingSupplier->id
|
|
])
|
|
->assertStatus(204);
|
|
|
|
$this->assertDatabaseMissing('setting_suppliers',[
|
|
'id' => $id
|
|
]);
|
|
}
|
|
|
|
}
|