user = factory(User::class)->create(); $this->company = $this->user->each(function ($u) { factory(Company::class)->create([ 'user_id' => $u->id, ]); }); } // TODO : those test is wrong, please redo later. // REDO the test public function testPost() { $response = $this->actingAs($this->user) ->postJson('/api/deliveryinfo', [ 'branch' => 'Testing', 'deli_info' => 'Testing', 'address' => 'Testing', 'city' => 'Testing', 'postcode' => '12345', 'state' => 'Testing', 'country' => 'Testing', 'contact_person' => 'Testing', 'contact_person_no' => '12345' ]); $response->assertStatus(201); } public function testPut() { $response = $this->actingAs($this->user) ->patchJson('/api/deliveryinfo', [ 'branch' => 'ChangedTesting', 'deli_info' => 'Testing', 'address' => 'Testing', 'city' => 'Testing', 'postcode' => '12345', 'state' => 'Testing', 'country' => 'Testing', 'contact_person' => 'Testing', 'contact_person_no' => '12345' ]); $response->assertStatus(200); } public function testDELETE() { $response = $this->json('DELETE', '/api/deliveryinfo'); $response->assertStatus(204); } }