'Widget', 'quantity' => 2, 'unitPriceInCents' => 1500, 'currency' => 'EUR'], ], ); $consumer($message); $invoice = $invoiceRepo->findByExternalOrderId('order-conformist-001'); self::assertNotNull($invoice, 'Invoicing (Conformist) must be able to consume sales.v1.OrderConfirmed.'); self::assertSame('order-conformist-001', $invoice->externalOrderId); self::assertCount(1, $invoice->lines()); } public function test_schema_backward_compatible_with_extra_fields(): void { // Simule un schema upstream avec un champ supplementaire (retro-compatible) $json = '{"orderId":"order-002","customerId":"cust-002","totalInCents":5000,"currency":"EUR","lines":[{"productName":"Gadget","quantity":1,"unitPriceInCents":5000,"currency":"EUR"}],"newField":"ignored"}'; $decoded = json_decode($json, true, flags: JSON_THROW_ON_ERROR); $message = new OrderConfirmed( orderId: $decoded['orderId'], customerId: $decoded['customerId'], totalInCents: $decoded['totalInCents'], currency: $decoded['currency'], lines: $decoded['lines'], ); self::assertSame('order-002', $message->orderId); self::assertSame(5000, $message->totalInCents); } }