faker = \Faker\Factory::create(); Model::reguard(); $this->makeTestData(); } public function testClientedDeletedAttemptingToCreateInvoice() { /* Test fire new invoice */ $data = [ 'client_id' => $this->client->hashed_id, 'number' => 'dude', ]; $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/invoices/', $data) ->assertStatus(200); $this->client->is_deleted = true; $this->client->save(); $data = [ 'client_id' => $this->client->hashed_id, 'number' => 'dude2', ]; $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/invoices/', $data) ->assertStatus(302); } }