id())->toBe($productId) ->and($product->name())->toBe($productName); }); it('rejects an empty name', function (): void { expect(fn (): Product => new Product(ProductId::generate(), '')) ->toThrow(\DomainException::class, 'Product name cannot be empty.'); }); it('considers two products with the same id as equal', function (): void { $productId = ProductId::generate(); $first = new Product($productId, 'New Product 1'); $second = new Product($productId, 'New Product 2'); expect($first->equals($second))->toBeTrue(); }); it('considers two products with different ids as not equal', function (): void { $productName = 'New Product'; $first = new Product(ProductId::generate(), $productName); $second = new Product(ProductId::generate(), $productName); expect($first->equals($second))->toBeFalse(); }); });