updated booking to create for current user

updated test to pass
This commit is contained in:
jack
2018-05-19 16:11:19 +08:00
parent 2783e874bf
commit 8f3a6d82e5
2 changed files with 34 additions and 28 deletions
+30 -25
View File
@@ -3,13 +3,23 @@
namespace Tests\Unit\BookingTest;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Database\Seeder;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Artisan;
use App\User;
class BookingTest extends TestCase
{
protected $user;
public function setUp()
{
parent::setUp();
Artisan::call('db:seed');
$this->user = factory(User::class)->create();
}
/**
* A basic test example.
*
@@ -36,27 +46,22 @@ class BookingTest extends TestCase
public function testPost()
{
$response = $this->json('POST', '/api/booking/', [
'account_name' => 'johnny',
'account_num' => '1234567',
'bank_name' => 'myabnak',
'bank_branch' => 'banking',
'company_name' => 'besaras',
'company_address' => 'californina',
'bank_address' => 'cyber',
'swift_code' => '123wert',
'cnap' => '2131rew',
'term' => 'x1_cash',
'amount' => '14000',
'user_id' => '1',
]);
dd($response->getContent());
$response
->assertStatus(201);
//dd($response->getContent());
$response =
$this->actingAs($this->user)
->postJson('/api/booking/', [
'account_name' => 'johnny',
'account_num' => '1234567',
'bank_name' => 'myabnak',
'bank_branch' => 'banking',
'company_name' => 'besaras',
'company_address' => 'californina',
'bank_address' => 'cyber',
'swift_code' => '123wert',
'cnap' => '2131rew',
'term' => 'x1_cash',
'amount' => '14000'
]);
$response->assertStatus(201);
}
// public function testPut()
@@ -85,4 +90,4 @@ class BookingTest extends TestCase
// $response->assertStatus(204);
// }
}
}