54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects;
|
|
|
|
use Carbon\CarbonImmutable;
|
|
use Domain\Enums\Country;
|
|
use Domain\Models\ValueObjects\CrmCustomer;
|
|
|
|
describe('CrmCustomer', function (): void {
|
|
it('can instantiate and convert to array', function (): void {
|
|
// GIVEN
|
|
$date = CarbonImmutable::parse('2026-06-12 10:00:00');
|
|
|
|
// WHEN
|
|
$customer = new CrmCustomer(
|
|
hashcode: 'hash',
|
|
email: 'test@example.com',
|
|
password: 'pass',
|
|
firstname: 'John',
|
|
lastname: 'Doe',
|
|
birthDate: '1990-01-01',
|
|
phone: '1234567890',
|
|
address: '1 rue',
|
|
address2: 'bis',
|
|
city: 'Paris',
|
|
postcode: '75001',
|
|
country: Country::france,
|
|
optIn: true,
|
|
status: true,
|
|
lastConnection: $date
|
|
);
|
|
|
|
// THEN
|
|
expect($customer->toArray())->toBe([
|
|
'hashcode' => 'hash',
|
|
'email' => 'test@example.com',
|
|
'password' => 'pass',
|
|
'firstname' => 'John',
|
|
'lastname' => 'Doe',
|
|
'birthDate' => '1990-01-01',
|
|
'phone' => '1234567890',
|
|
'address' => '1 rue',
|
|
'address2' => 'bis',
|
|
'city' => 'Paris',
|
|
'postcode' => '75001',
|
|
'country' => Country::france,
|
|
'optIn' => true,
|
|
'status' => true,
|
|
'lastConnection' => $date,
|
|
]);
|
|
});
|
|
});
|