mirror of
https://gitlab.com/omair-personal/exchange.git
synced 2026-08-19 12:34:13 +00:00
68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?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;
|
|
use App\User;
|
|
use App\SettingCredit;
|
|
use App\Booking;
|
|
use App\UserBankSlip;
|
|
use App\Role;
|
|
|
|
class ChinaBankSlipTest extends TestCase
|
|
{
|
|
protected $user;
|
|
protected $booking;
|
|
protected $userBankSlip;
|
|
protected $setting_credit;
|
|
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
|
|
\DB::statement('SET FOREIGN_KEY_CHECKS=0');
|
|
Artisan::call('db:seed');
|
|
\DB::statement('SET FOREIGN_KEY_CHECKS=1');
|
|
|
|
$this->user = factory(User::class)->create();
|
|
$this->setting_credit = factory(SettingCredit::class)->create();
|
|
$this->booking = factory(Booking::class)->create([
|
|
'user_id' => $this->user->id
|
|
]);
|
|
$this->userBankSlip = factory(UserBankSlip::class)->create([
|
|
'booking_id' => $this->booking->id
|
|
]);
|
|
}
|
|
/**
|
|
* A basic test example.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testCreate(){
|
|
$this->user->attachRole(Role::Where('name','admin')->first());
|
|
Storage::fake('file');
|
|
$size_in_kb = 3072; // 3072KB = 3MB
|
|
$china_bank_slips_path = UploadedFile::fake()->image('comp.jpg')->size($size_in_kb);
|
|
$response =
|
|
$this->actingAs($this->user)->
|
|
postJson('/api/booking/'. $this->booking->id .'/upload-china-bankslip',[
|
|
'file' => $china_bank_slips_path,
|
|
'actual_transfer_amount' => '12',
|
|
'details' => "123123",
|
|
'date' => "123123"
|
|
]);
|
|
dd($response->getContent());
|
|
if(!file_exists($china_bank_slips_path) || $size_in_kb > 3072){
|
|
$response->assertStatus(400);
|
|
}
|
|
else{
|
|
$response->assertSuccessful();
|
|
}
|
|
}
|
|
}
|