Add test for settingcredit and rate

This commit is contained in:
Too
2018-06-19 18:56:31 +08:00
parent 1b39ee8bda
commit 95f4f25dd3
6 changed files with 124 additions and 18 deletions
+4 -1
View File
@@ -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()
+61
View File
@@ -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);
}
}
+35
View File
@@ -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);
}
}
+2
View File
@@ -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));
}
}