mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-19 04:24:01 +00:00
redo contact test, added contact factory
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Contact::class, function (Faker $faker) {
|
||||
return [
|
||||
'user_id' => '1',
|
||||
'com_id' => '1',
|
||||
'status' => '1',
|
||||
];
|
||||
});
|
||||
+37
-32
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user