value)->toBe($value) ->and($code->availableIn)->toBe(Country::FRANCE); }); it('rejects an invalid value', function (string $invalidValue): void { // GIVEN / WHEN $action = fn (): CouponProcessingCode => new CouponProcessingCode($invalidValue, Country::FRANCE); // THEN expect($action)->toThrow(\DomainException::class, 'Processing Code must be exactly 13 numeric characters'); })->with([ 'empty' => '', 'too short' => '542500394413', 'too long' => '54250039441301', 'with letters' => 'ABC1234567890', 'special char' => '542500394413!', 'with space' => '5425 03944130', 'trailing break' => "5425003944130\n", ]); it('is equal to another processing code with the same value', function () use ($value): void { // GIVEN $code = new CouponProcessingCode($value, Country::FRANCE); $other = new CouponProcessingCode($value, Country::FRANCE); // WHEN / THEN expect($code->equals($other))->toBeTrue(); }); it('ignores the country when comparing', function () use ($value): void { // GIVEN $france = new CouponProcessingCode($value, Country::FRANCE); $benelux = new CouponProcessingCode($value, Country::BENELUX); // WHEN / THEN expect($france->equals($benelux))->toBeTrue(); }); it('is not equal to a processing code with a different value', function () use ($value): void { // GIVEN $code = new CouponProcessingCode($value, Country::FRANCE); $other = new CouponProcessingCode('4006381333931', Country::FRANCE); // WHEN / THEN expect($code->equals($other))->toBeFalse(); }); it('is not equal to a value that is not a processing code', function () use ($value): void { // GIVEN $code = new CouponProcessingCode($value, Country::FRANCE); // WHEN / THEN expect($code->equals($value))->toBeFalse() ->and($code->equals(null))->toBeFalse(); }); it('is converted to its value as a string', function () use ($value): void { // GIVEN $code = new CouponProcessingCode($value, Country::FRANCE); // WHEN / THEN expect((string) $code)->toBe($value); }); });