Step 02 — Conformist (Invoicing)
- Ajout Symfony Messenger comme bus d'intégration - MessengerSalesEventPublisher remplace le NaivePublisher pour dispatch via Messenger - WhenOrderConfirmed (Invoicing) : consumer Conformist qui consomme sales.v1.OrderConfirmed tel quel - Tests de compatibilité Conformist et intégration - Configuration Messenger avec transport sync
This commit is contained in:
48
tests/Integration/InvoicingConformistTest.php
Normal file
48
tests/Integration/InvoicingConformistTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MiniShop\Tests\Integration;
|
||||
|
||||
use MiniShop\Contracts\Sales\V1\Event\OrderConfirmed;
|
||||
use MiniShop\Invoicing\Infrastructure\Persistence\InMemoryInvoiceRepository;
|
||||
use MiniShop\Invoicing\Infrastructure\SequentialInvoiceNumberGenerator;
|
||||
use MiniShop\Invoicing\Interfaces\Messaging\WhenOrderConfirmed;
|
||||
use MiniShop\Invoicing\Application\Command\IssueInvoiceForExternalOrderHandler;
|
||||
use MiniShop\Shared\Technical\SystemClock;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test d'integration : le consumer Conformist d'Invoicing recoit un message
|
||||
* sales.v1.OrderConfirmed et cree une facture sans traduction.
|
||||
*/
|
||||
final class InvoicingConformistTest extends TestCase
|
||||
{
|
||||
public function test_invoicing_creates_invoice_on_order_confirmed(): void
|
||||
{
|
||||
$invoiceRepo = new InMemoryInvoiceRepository();
|
||||
$consumer = new WhenOrderConfirmed(
|
||||
new IssueInvoiceForExternalOrderHandler(
|
||||
$invoiceRepo,
|
||||
new SequentialInvoiceNumberGenerator(),
|
||||
new SystemClock(),
|
||||
),
|
||||
);
|
||||
|
||||
$consumer(new OrderConfirmed(
|
||||
orderId: 'order-int-001',
|
||||
customerId: 'cust-001',
|
||||
totalInCents: 4500,
|
||||
currency: 'EUR',
|
||||
lines: [
|
||||
['productName' => 'Widget', 'quantity' => 2, 'unitPriceInCents' => 1500, 'currency' => 'EUR'],
|
||||
['productName' => 'Gadget', 'quantity' => 1, 'unitPriceInCents' => 1500, 'currency' => 'EUR'],
|
||||
],
|
||||
));
|
||||
|
||||
$invoice = $invoiceRepo->findByExternalOrderId('order-int-001');
|
||||
self::assertNotNull($invoice);
|
||||
self::assertCount(2, $invoice->lines());
|
||||
self::assertSame('INV-000001', $invoice->invoiceNumber);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user