mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 04:14:04 +00:00
Merge branch 'too/testsettingsuppliers' into 'master'
Add test for setting supplier See merge request CIEFWorldwideSdnBhd/exchange!39
This commit is contained in:
@@ -19,11 +19,13 @@ class BookingController extends Controller
|
||||
{
|
||||
|
||||
public function index(){
|
||||
|
||||
$user = Auth::user();
|
||||
$bookings = Booking::select('id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status')
|
||||
->where('user_id', $user->id)
|
||||
->get();
|
||||
|
||||
$bookings = Booking::select('id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status')
|
||||
->where('user_id', $user->id)
|
||||
->get();
|
||||
|
||||
|
||||
// reformat to fit frontend structure
|
||||
foreach ($bookings as $booking) {
|
||||
// set timeout
|
||||
|
||||
@@ -4,6 +4,10 @@ use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\SettingSupplier::class, function (Faker $faker) {
|
||||
return [
|
||||
//
|
||||
'company_name' => $faker->name,
|
||||
'gst_no' => $faker->unique()->randomDigit,
|
||||
'supplier_reg_no' => $faker->unique()->randomDigit,
|
||||
'bank_name' => $faker->name,
|
||||
'acc_no' => $faker->unique()->randomDigit
|
||||
];
|
||||
});
|
||||
|
||||
Generated
+537
-627
File diff suppressed because it is too large
Load Diff
+2
-1
@@ -32,7 +32,8 @@
|
||||
"vue-meta": "^1.4.4",
|
||||
"vue-router": "^3.0.1",
|
||||
"vuex": "^3.0.1",
|
||||
"vuex-router-sync": "^5.0.0"
|
||||
"vuex-router-sync": "^5.0.0",
|
||||
"webpack": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-eslint": "^3.0.0-beta.6",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"/js/lang-zh-CN.c0da3973e52421a8cfe5.js": "/js/lang-zh-CN.c0da3973e52421a8cfe5.js",
|
||||
"/js/lang-es.f4a1a5b4a30e92527b46.js": "/js/lang-es.f4a1a5b4a30e92527b46.js",
|
||||
"/js/lang-en.0f790217417404ecc662.js": "/js/lang-en.0f790217417404ecc662.js",
|
||||
"/js/lang-zh-CN.1eaced19dec8880e8788.js": "/js/lang-zh-CN.1eaced19dec8880e8788.js",
|
||||
"/js/lang-es.8f478e6e7ba5b47cb57f.js": "/js/lang-es.8f478e6e7ba5b47cb57f.js",
|
||||
"/js/lang-en.118567ba566d80e1464a.js": "/js/lang-en.118567ba566d80e1464a.js",
|
||||
"/js/app.js": "/js/app.js",
|
||||
"/css/app.css": "/css/app.css"
|
||||
}
|
||||
+2
-1
@@ -42,8 +42,9 @@ Route::group(['middleware' => 'auth:api'], function () {
|
||||
Route::post('booking/{book_id}/reject-bank-slip','BookingController@rejectBankSlip');
|
||||
Route::post('booking/{book_id}/approve-bank-slip','BookingController@approveBankSlip');
|
||||
Route::post('booking/{book_id}/cancel', 'BookingController@cancel');
|
||||
Route::get('/booking', 'BookingController@index');
|
||||
Route::get('/booking', 'BookingController@index');
|
||||
Route::get('/user', 'UserController@show');
|
||||
|
||||
Route::patch('settings/profile', 'Settings\ProfileController@update');
|
||||
Route::patch('settings/password', 'Settings\PasswordController@update');
|
||||
});
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<?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
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user