Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/exchange into too/gitlabci

# Conflicts:
#	app/Http/Controllers/BookingController.php
#	app/Http/Kernel.php
#	composer.lock
This commit is contained in:
Jack Goh
2018-07-31 16:30:26 +08:00
180 changed files with 24784 additions and 7056 deletions
+48 -24
View File
@@ -4,6 +4,7 @@ namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Database\Seeder;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\Storage;
@@ -16,12 +17,14 @@ use App\User;
use App\Booking;
use App\UserBankSlip;
use App\Role;
use App\SettingCredit;
class BookingTest extends TestCase
{
protected $user;
protected $booking;
protected $userBankSlip;
protected $setting_credit;
public function setUp()
{
@@ -29,6 +32,7 @@ class BookingTest extends TestCase
Artisan::call('db:seed');
$this->user = factory(User::class)->create();
$this->setting_credit = factory(SettingCredit::class)->create();
$this->booking = factory(Booking::class)->create([
'user_id' => $this->user->id
]);
@@ -67,24 +71,34 @@ class BookingTest extends TestCase
'usd_book_cnap' => '2131rew',
'usd_book_bank_branch' => '2131rew',
'verification_status' => '1'
])
->assertStatus(201);
]);
if(14000 > $this->setting_credit->rmb_credit_limit){
$response->assertStatus(401);
}
else{
$response->assertStatus(201);
}
}
public function testuploadbankslip()
{
Storage::fake('file');
$bankslip_path = UploadedFile::fake()->image('comp.jpg');
if(!file_exists($bankslip_path)){
$response->assertStatus(400);
}
$size_in_kb = 3072; // 3072KB = 3MB
$bankslip_path = UploadedFile::fake()->image('comp.jpg')->size($size_in_kb);
$response =
$this->actingAs($this->user)
->json('POST', '/api/booking/' . $this->booking->id . '/upload-user-bankslip', [
'file' => $bankslip_path
])
->assertSuccessful();
]);
if(!file_exists($bankslip_path) || $size_in_kb > 3072){
$response->assertStatus(400);
}
else{
$response->assertSuccessful();
}
}
public function testUpdateBankslipAmount()
@@ -99,18 +113,22 @@ class BookingTest extends TestCase
public function testuploadPO()
{
Storage::fake('file');
$image_path = UploadedFile::fake()->image('comp.jpg');
if(!file_exists($image_path)){
$response->assertStatus(400);
}
$size_in_kb = 3072; // 3072KB = 3MB
$image_path = UploadedFile::fake()->image('comp.jpg')->size($size_in_kb);
$response =
$this->actingAs($this->user)
->json('POST', '/api/booking/' . $this->booking->id . '/upload-po', [
'file' => $image_path,
'amount' => '12345'
])
->assertSuccessful();
]);
if(!file_exists($image_path) || $size_in_kb > 3072){
$response->assertStatus(400);
}
else{
$response->assertSuccessful();
}
}
public function testCancel()
@@ -123,7 +141,9 @@ class BookingTest extends TestCase
public function testApproveBankSlip()
{
$this->actingAs($this->user)
->json('POST','/api/booking/' . $this->booking->id . '/approve-bank-slip', [])
->json('POST','/api/booking/' . $this->booking->id . '/approve-bank-slip', [
'estimated_arrival_time' => '6000'
])
->assertSuccessful();
}
@@ -141,18 +161,22 @@ class BookingTest extends TestCase
$this->user->roles()->sync([]);
$this->user->attachRole(Role::Where('name','admin')->first());
$size_in_kb = 3072;
Storage::fake('invoice_path');
$invoice_path = UploadedFile::fake()->create('document.pdf');
if(!file_exists($invoice_path)){
$response->assertStatus(400);
}
$invoice_path = UploadedFile::fake()->create('document.pdf',$size_in_kb);
$response =
$this->actingAs($this->user)
->json('POST', '/api/booking/' . $this->booking->id . '/upload-invoice', [
'invoice_path' => $invoice_path,
'amount' => '12345'
])
->assertSuccessful();
]);
if(!file_exists($invoice_path) || $size_in_kb > 3072){
$response->assertStatus(400);
}
else{
$response->assertSuccessful();
}
}
}
+39
View File
@@ -0,0 +1,39 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\UploadedFile;
use Artisan;
class ChinaBankSlipTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testStore(){
Storage::fake('file');
$size_in_kb = 3072; // 3072KB = 3MB
$china_bank_slips_path = UploadedFile::fake()->image('comp.jpg')->size($size_in_kb);
$response =
$this->postJson('api/upload-china-bankslip',[
'china_bank_slips' => $china_bank_slips_path,
'actual_transfer_amount' => '12',
'details' => "123123",
'date' => "123123"
]);
if(!file_exists($china_bank_slips_path) || $size_in_kb > 3072){
$response->assertStatus(400);
}
else{
$response->assertSuccessful();
}
}
}
+2 -2
View File
@@ -13,8 +13,8 @@ class LoginTest extends TestCase
public function setUp()
{
parent::setUp();
$this->user = factory(User::class)->create();
$this->withoutExceptionHandling();
}
/** @test */
@@ -35,7 +35,7 @@ class LoginTest extends TestCase
$this->actingAs($this->user)
->getJson('/api/user')
->assertSuccessful()
->assertJsonStructure(['id', 'name', 'email']);
->assertJsonStructure(['id', 'name', 'email', 'marking']);
}
/** @test */
+9 -2
View File
@@ -43,8 +43,8 @@ class RateTest extends TestCase
'x2_ba' => '1.2'
])
->assertStatus(201);
}
}
public function testUpdate(){
$response =
$this->actingAs($this->user)
@@ -57,5 +57,12 @@ class RateTest extends TestCase
'x2_ba' => '1.2'
])
->assertStatus(200);
}
public function testShowRate(){
$response = $this->json('GET', '/api/rate');
$response
->assertStatus(200);
}
}
+1 -2
View File
@@ -22,13 +22,12 @@ class RegisterTest extends TestCase
public function can_register()
{
$this->postJson('/api/register', [
'name' => 'Test User',
'email' => $this->marking->email,
'password' => 'secret',
'password_confirmation' => 'secret',
'marking' => $this->marking->marking
])
->assertSuccessful()
->assertJsonStructure(['id', 'name', 'email']);
->assertJsonStructure(['id','email']);
}
}
+3 -1
View File
@@ -24,10 +24,12 @@ class SettingCreditTest extends TestCase
}
public function testStore(){
$this->actingAs($this->user)
->postJson('/api/setting-credit/', [
'rmb_credit_limit' => '5000',
'usd_credit_limit' => '2000'
'usd_credit_limit' => '2000',
'time_limit' => '500'
])
->assertStatus(201);
}
+68
View File
@@ -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
]);
}
}