Files
DDDBoilerplate/tests/Integration/LegacyFulfillmentAclTest.php
Mathias STRASSER b356033f7b Step 05 — Hardening
- CorrelationId VO pour le tracing inter-BC
- IdempotencyStore (interface + InMemory) pour garde d'idempotence
- correlationId ajouté aux contrats Published Language (retro-compatible par défaut)
- Consumers Invoicing et LegacyFulfillment idempotents avec logging
- MessengerSalesEventPublisher propage les correlationIds
- Tests unitaires idempotence + tests d'intégration consommateurs idempotents
2026-03-04 00:35:20 +01:00

50 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace MiniShop\Tests\Integration;
use MiniShop\Contracts\Sales\V1\Event\OrderConfirmed;
use MiniShop\LegacyFulfillment\Application\Command\RequestShipmentFromSalesOrderHandler;
use MiniShop\LegacyFulfillment\Domain\Model\LegacyOrderRef;
use MiniShop\LegacyFulfillment\Infrastructure\AntiCorruption\LegacyShipmentAcl;
use MiniShop\LegacyFulfillment\Infrastructure\Gateway\FakeLegacyFulfillmentGateway;
use MiniShop\LegacyFulfillment\Infrastructure\Persistence\InMemoryShipmentRequestRepository;
use MiniShop\LegacyFulfillment\Interfaces\Messaging\WhenOrderConfirmed;
use MiniShop\Shared\Technical\InMemoryIdempotencyStore;
use MiniShop\Shared\Technical\SystemClock;
use PHPUnit\Framework\TestCase;
/**
* Test d'integration : le consumer ACL de LegacyFulfillment recoit un message
* sales.v1.OrderConfirmed, le traduit via l'ACL, et cree une demande d'expedition.
*/
final class LegacyFulfillmentAclTest extends TestCase
{
public function test_acl_consumer_creates_shipment_from_contract(): void
{
$shipmentRepo = new InMemoryShipmentRequestRepository();
$gateway = new FakeLegacyFulfillmentGateway();
$consumer = new WhenOrderConfirmed(
new LegacyShipmentAcl(),
new RequestShipmentFromSalesOrderHandler($shipmentRepo, $gateway, new SystemClock()),
new InMemoryIdempotencyStore(),
);
$consumer(new OrderConfirmed(
orderId: 'order-acl-int-001',
customerId: 'cust-001',
totalInCents: 3000,
currency: 'EUR',
lines: [
['productName' => 'Widget', 'quantity' => 2, 'unitPriceInCents' => 1500, 'currency' => 'EUR'],
],
));
$shipment = $shipmentRepo->findByOrderRef(LegacyOrderRef::fromExternalId('order-acl-int-001'));
self::assertNotNull($shipment, 'ACL consumer must create a shipment request.');
self::assertCount(1, $gateway->sentRequests());
}
}