completed the user intergration

This commit is contained in:
Zain Fauzan Rofie Azizi
2018-06-12 09:49:24 +08:00
parent 5909f50cd3
commit f463d0b6b2
15 changed files with 148 additions and 237 deletions
+28 -41
View File
@@ -7,57 +7,35 @@ use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Artisan;
use App\Deliveryinfo;
class DeliveryinfoTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testGET()
{
$response = $this->json('GET', '/api/company/deliveryinfo');
protected $company;
protected $user;
$response->assertStatus(200);
public function setUp()
{
parent::setUp();
Artisan::call('db:seed');
$this->user = factory(User::class)->create();
$this->company = $this->user->each(function ($u) {
factory(Company::class)->create([
'user_id' => $u->id,
]);
});
}
public function testPOST()
public function testPUT()
{
$response = $this->json('POST', '/api/company/com_id/deliveryinfo', [
$response = $this->actingAs($this->company)
->patchJson('/api/deliveryinfo', [
'branch' => 'Testing',
'deli_info' => 'Testing',
'address' => 'Testing',
'city' => 'Testing',
'postcode' => '12345',
'state' => 'Testing',
'country' => 'Testing',
'contact_person' => 'Testing',
'contact_person_no' => '12345',
]);
$response->assertStatus(201);
}
public function testDELETE()
{
$response = $this->json('DELETE', '/api/company/4/deliveryinfo');
$response->assertStatus(204);
}
public function testPUT()
{
$response = $this->json('PUT', '/api/company/1/deliveryinfo', [
//'id' => '1',
'branch' => 'Ci',
'deli_info' => 'Testing',
'address' => 'Testing',
'city' => 'Test',
'postcode' => '12345',
'state' => 'Testing',
@@ -67,6 +45,15 @@ class DeliveryinfoTest extends TestCase
]);
$response->assertStatus(200);
$response->assertStatus(200);
}
public function testDELETE()
{
$response = $this->json('DELETE', '/api/company/1/deliveryinfo');
$response->assertStatus(204);
}
}