71 lines
1.7 KiB
PHP
71 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Tests\Client;
|
|
|
|
use App\Models\Claim as ModelsClaim;
|
|
use LDC\LDCCRM\Models\Claim;
|
|
use Illuminate\Http\UploadedFile;
|
|
use LDC\LDCCRM\Exceptions\ValidationException;
|
|
|
|
class CrmClientClaimTest extends CrmClientTester
|
|
{
|
|
/**
|
|
* Create new claim.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testCreateClaim(): void
|
|
{
|
|
$image = UploadedFile::fake()->image('photo.jpg');
|
|
$this->assertTrue(Claim::setClaim(
|
|
'Jean',
|
|
'Bond',
|
|
'claim@hotmail.fr',
|
|
'Ceci est un message.',
|
|
1,
|
|
1,
|
|
'10 rue des totos',
|
|
'Le Mans',
|
|
'72100',
|
|
base64_encode(file_get_contents($image->getRealPath())),
|
|
));
|
|
$this->assertTrue(ModelsClaim::query()->where('email', 'claim@hotmail.fr')->exists());
|
|
}
|
|
|
|
/**
|
|
* 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());
|
|
}
|
|
}
|