makeTestData(); $this->withoutMiddleware( ThrottleRequests::class ); } public function testCompanyDocumentExists() { $company_key = $this->company->company_key; $original_count = Document::whereCompanyId($this->company->id)->count(); $image = UploadedFile::fake()->image('avatar.jpg'); $document = UploadFile::dispatchNow( $image, UploadFile::IMAGE, $this->user, $this->company, $this->invoice ); $this->assertNotNull($document); $this->assertTrue(Storage::exists($document->url)); $this->assertGreaterThan($original_count, Document::whereCompanyId($this->company->id)->count()); $this->company->delete(); $this->assertEquals(0, Document::whereCompanyId($this->company->id)->count()); $this->assertFalse(Storage::exists($document->url)); } }