toArray())->toBe([ 'name' => 'Name', 'address' => '1 rue', 'postcode' => '75001', 'city' => 'Paris', 'phone' => '0123456789', 'latitude' => '48.8', 'longitude' => '2.3', ]); }); it('throws exception if name is empty', function (): void { // GIVEN // WHEN $action = fn () => new DeliveryAddress('', '1 rue', '75001', 'Paris'); // THEN expect($action)->toThrow(\DomainException::class, 'Store name cannot be empty.'); }); it('throws exception if address is empty', function (): void { // GIVEN // WHEN $action = fn () => new DeliveryAddress('Name', '', '75001', 'Paris'); // THEN expect($action)->toThrow(\DomainException::class, 'Address cannot be empty.'); }); it('throws exception if postcode is empty', function (): void { // GIVEN // WHEN $action = fn () => new DeliveryAddress('Name', '1 rue', '', 'Paris'); // THEN expect($action)->toThrow(\DomainException::class, 'Postcode cannot be empty.'); }); it('throws exception if city is empty', function (): void { // GIVEN // WHEN $action = fn () => new DeliveryAddress('Name', '1 rue', '75001', ''); // THEN expect($action)->toThrow(\DomainException::class, 'City cannot be empty.'); }); it('throws exception if latitude is set without longitude', function (): void { // GIVEN // WHEN $action = fn () => new DeliveryAddress('Name', '1 rue', '75001', 'Paris', null, '48.8', null); // THEN expect($action)->toThrow(\DomainException::class, 'Longitude must be provided if latitude is.'); }); });