redo contact test, added contact factory

This commit is contained in:
Zain Fauzan Rofie Azizi
2018-07-02 16:50:18 +08:00
parent 7a7e8fdcfe
commit 03d84570fa
2 changed files with 48 additions and 32 deletions
+37 -32
View File
@@ -1,52 +1,57 @@
<?php
namespace Tests\Unit\contactTest;
namespace Tests\API;
namespace Tests\Unit\ContactTest;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Artisan;
use App\User;
use App\Company;
class ContactTest extends TestCase
{
protected $company;
protected $user;
public function testGet()
{
$response = $this->json('GET', '/api/company/search/cief');
$response
->assertStatus(200);
}
public function testStoreId()
public function setUp()
{
$response = $this->json('POST', '/api/contacts', ['company_id' => '1'], $this->headers());
$response
->assertStatus(201);
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()
{
$response = $this->actingAs($this->user)
->postJson('/api/contact', [
'com_id' => '1',
]);
$response->assertStatus(200);
}
// public function testDeleteContacts()
// {
//
// $response = $this->json('DELETE', '/api/contacts/1');
//
// $response
// ->assertStatus(204);
//
// }
public function testApproved()
{
$response = $this->actingAs($this->user)
->postJson('/api/contact/1/', [
'user_id' => '1',
'com_id' => '1',
'status' => '1',
]);
$response->assertStatus(200);
}
public function testApprove()
{
$response = $this->json('POST', '/api/contacts/1/request', ['action' => 1]);
$response
->assertStatus(200);
}
}