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 testApproved() { $response = $this->actingAs($this->user) ->postJson('/api/contact/1/', [ 'user_id' => '1', 'com_id' => '1', 'status' => '1', ]); $response->assertStatus(200); } }