mirror of
https://gitlab.com/omair-personal/exchange.git
synced 2026-08-19 04:24:08 +00:00
Add test for settingcredit and rate
This commit is contained in:
@@ -104,7 +104,7 @@ class BookingController extends Controller
|
||||
$booking->bia = $bia;
|
||||
// $booking->user_id = $user->id;
|
||||
$booking->user()->associate($user);
|
||||
$booking->save();
|
||||
|
||||
|
||||
// The test failed due to ->save() before filling up the information at below
|
||||
|
||||
@@ -113,22 +113,22 @@ class BookingController extends Controller
|
||||
// $booking->rmb_book_account_name = $request->input('rmb_book_account_name');
|
||||
// $booking->rmb_book_acc_no = $request->input('rmb_book_acc_no');
|
||||
// $booking->rmb_book_bank_branch = $request->input('rmb_book_bank_branch');
|
||||
// $booking->company_name = $request->input('company_name');
|
||||
// $booking->company_address = $request->input('company_address');
|
||||
// $booking->bank_address = $request->input('bank_address');
|
||||
// $booking->swift_code = $request->input('swift_code');
|
||||
// $booking->cnap = $request->input('cnap');
|
||||
// $booking->term = $request->input('term');
|
||||
|
||||
// $booking->usd_book_amount = $request->input('usd_book_amount');
|
||||
// $booking->usd_book_pay_method = $request->input('usd_book_pay_method');
|
||||
// $booking->usd_book_company_name = $request->input('usd_book_company_name');
|
||||
// $booking->usd_book_company_address = $request->input('usd_book_company_address');
|
||||
// $booking->usd_book_swift_code = $request->input('usd_book_swift_code');
|
||||
// $booking->usd_book_cnap = $request->input('usd_book_cnap');
|
||||
// $booking->usd_book_bank_branch = $request->input('usd_book_bank_branch');
|
||||
// $booking->verification_status = $request->input('verification_status');
|
||||
// $booking->company_name = $request->input('company_name');
|
||||
// $booking->company_address = $request->input('company_address');
|
||||
// $booking->bank_address = $request->input('bank_address');
|
||||
// $booking->swift_code = $request->input('swift_code');
|
||||
// $booking->cnap = $request->input('cnap');
|
||||
// $booking->term = $request->input('term');
|
||||
|
||||
// $booking->usd_book_amount = $request->input('usd_book_amount');
|
||||
// $booking->usd_book_pay_method = $request->input('usd_book_pay_method');
|
||||
// $booking->usd_book_company_name = $request->input('usd_book_company_name');
|
||||
// $booking->usd_book_company_address = $request->input('usd_book_company_address');
|
||||
// $booking->usd_book_swift_code = $request->input('usd_book_swift_code');
|
||||
// $booking->usd_book_cnap = $request->input('usd_book_cnap');
|
||||
// $booking->usd_book_bank_branch = $request->input('usd_book_bank_branch');
|
||||
// $booking->verification_status = $request->input('verification_status');
|
||||
$booking->save();
|
||||
return response()->json($booking, 201);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,11 @@ use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Rate::class, function (Faker $faker) {
|
||||
return [
|
||||
//
|
||||
'x1_cash' => $faker->randomDigit,
|
||||
'x1_cheque' => $faker->randomDigit,
|
||||
'x1_ba' => $faker->randomDigit,
|
||||
'x2_cash' => $faker->randomDigit,
|
||||
'x2_cheque' => $faker->randomDigit,
|
||||
'x2_ba' => $faker->randomDigit
|
||||
];
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\BookingTest;
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
@@ -15,6 +15,7 @@ use Artisan;
|
||||
use App\User;
|
||||
use App\Booking;
|
||||
use App\UserBankSlip;
|
||||
use App\Role;
|
||||
|
||||
class BookingTest extends TestCase
|
||||
{
|
||||
@@ -26,6 +27,7 @@ class BookingTest extends TestCase
|
||||
{
|
||||
parent::setUp();
|
||||
Artisan::call('db:seed');
|
||||
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->booking = factory(Booking::class)->create([
|
||||
'user_id' => $this->user->id
|
||||
@@ -33,6 +35,7 @@ class BookingTest extends TestCase
|
||||
$this->userBankSlip = factory(UserBankSlip::class)->create([
|
||||
'booking_id' => $this->booking->id
|
||||
]);
|
||||
$this->user->attachRole(Role::Where('name','member')->first());
|
||||
}
|
||||
|
||||
public function testPost()
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use App\Role;
|
||||
use Artisan;
|
||||
use App\User;
|
||||
use App\Rate;
|
||||
|
||||
class RateTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
protected $user;
|
||||
protected $rate;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Artisan::call('db:seed');
|
||||
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->rate = factory(Rate::class)->create();
|
||||
$this->user->attachRole(Role::Where('name','admin')->first());
|
||||
}
|
||||
|
||||
public function testStore(){
|
||||
$response =
|
||||
$this->actingAs($this->user)
|
||||
->postJson('/api/update-rate/',[
|
||||
'x1_cash' => '1.2',
|
||||
'x1_cheque' => '1.2',
|
||||
'x1_ba' => '1.2',
|
||||
'x2_cash' => '1.2',
|
||||
'x2_cheque' => '1.2',
|
||||
'x2_ba' => '1.2'
|
||||
])
|
||||
->assertStatus(201);
|
||||
}
|
||||
|
||||
public function testUpdate(){
|
||||
$response =
|
||||
$this->actingAs($this->user)
|
||||
->json('PUT','/api/update-rate/' . $this->rate->id,[
|
||||
'x1_cash' => '1.2',
|
||||
'x1_cheque' => '1.2',
|
||||
'x1_ba' => '1.2',
|
||||
'x2_cash' => '1.2',
|
||||
'x2_cheque' => '1.2',
|
||||
'x2_ba' => '1.2'
|
||||
])
|
||||
->assertStatus(200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use App\User;
|
||||
use App\SettingCredit;
|
||||
use App\Role;
|
||||
use Artisan;
|
||||
|
||||
class SettingCreditTest extends TestCase
|
||||
{
|
||||
protected $user;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Artisan::call('db:seed');
|
||||
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->user->attachRole(Role::Where('name','admin')->first());
|
||||
}
|
||||
|
||||
public function testStore(){
|
||||
$this->actingAs($this->user)
|
||||
->postJson('/api/setting-credit/', [
|
||||
'rmb_credit_limit' => '5000',
|
||||
'usd_credit_limit' => '2000'
|
||||
])
|
||||
->assertStatus(201);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace Tests\Feature;
|
||||
|
||||
use App\User;
|
||||
use Tests\TestCase;
|
||||
use App\Role;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class SettingsTest extends TestCase
|
||||
@@ -48,4 +49,5 @@ class SettingsTest extends TestCase
|
||||
|
||||
$this->assertTrue(Hash::check('updated', $this->user->password));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user