diff --git a/database/factories/ContactFactory.php b/database/factories/ContactFactory.php new file mode 100644 index 0000000..52a211b --- /dev/null +++ b/database/factories/ContactFactory.php @@ -0,0 +1,11 @@ +define(App\Contact::class, function (Faker $faker) { + return [ + 'user_id' => '1', + 'com_id' => '1', + 'status' => '1', + ]; +}); diff --git a/tests/Unit/contactTest.php b/tests/Unit/contactTest.php index 44ded98..1402530 100644 --- a/tests/Unit/contactTest.php +++ b/tests/Unit/contactTest.php @@ -1,52 +1,57 @@ 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); - - } }