image('photo.jpg'); $base64 = base64_encode(file_get_contents($image->getRealPath())); $this->assertTrue(Claim::setClaim( 'Jean', 'Bond', 'claim@hotmail.fr', 'Ceci est un message.', 1, 1, '10 rue des totos', 'Le Mans', '72100', $base64, )); $this->assertTrue(ModelsClaim::query()->where('email', 'claim@hotmail.fr')->exists()); $claimModel = ModelsClaim::query()->where('email', 'claim@hotmail.fr')->firstOrFail(); $this->assertNotEmpty($claimModel->file, 'The "file" field is empty on the Claim model.'); $this->assertTrue( Storage::disk('public')->exists(str_replace('storage/', '', $claimModel->file)), "The file does not exist: {$claimModel->file}" ); } /** * Create new claim without optionnal fields. * * @return void */ public function testCreateClaimWithoutOptionnalFields(): void { $this->assertTrue(Claim::setClaim( 'Jean', 'Bond', 'claim@hotmail.fr', 'Ceci est un message.', 1, 1, )); $this->assertTrue(ModelsClaim::query()->where('email', 'claim@hotmail.fr')->exists()); } /** * Create new claim should fail. * * @return void */ public function testCreateClaimShouldFail(): void { $this->expectException(ValidationException::class); Claim::setClaim( 'Jean', 'Bond', 'claim@hotmail.fr', 'Ceci est un message.', 0, 0, ); $this->assertSame(0, ModelsClaim::count()); } }