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/warehouse', [ 'address'=> 'Testing', 'city'=>'Testing ', 'zip'=>' Testing', 'state' =>'Testing', 'contact_person' =>'Testing ', 'contact_person_no' =>'12345 ', 'branch'=>'Testing ', 'country' =>' Testing', 'com_id' =>'99' ]); $response->assertStatus(201); } public function testUpdate() { $response = $this->actingAs($this->user) ->patchJson('/api/warehouse', [ 'address' => 'Changed Testing', 'city' => 'Testing ', 'zip' => ' Testing', 'state' => 'Testing', 'contact_person' => 'Testing ', 'contact_person_no' => '12345 ', 'branch' => 'Testing ', 'country' => ' Testing', 'com_id' => '99' ]); $response->assertStatus(201); } public function testDelete() { $this->actingAs($this->user) ->json('DELETE', '/api/so/99'); $response->assertStatus(204); } }