Add file size checking. Rename bankslip_url to china_bank_slip_path in chinabankslip table

This commit is contained in:
Too
2018-06-26 22:23:10 +08:00
parent fdcaa31ffe
commit 436b284a3b
5 changed files with 86 additions and 4 deletions
-1
View File
@@ -17,7 +17,6 @@ use App\Booking;
use App\UserBankSlip;
use App\Role;
use App\SettingCredit;
use Illuminate\Support\Facades\File;
class BookingTest extends TestCase
{
+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();
}
}
}