Step 03 — ACL (LegacyFulfillment)

- LegacyShipmentAcl : mapping explicite sales.v1.OrderConfirmed → LegacyCreateShipmentCommand
- LegacyCreateShipmentCommand : modèle legacy (champs abrégés, codification date/status)
- WhenOrderConfirmed (LegacyFulfillment) : consumer Messenger via ACL
- Tests unitaires mapping ACL + test d'intégration
This commit is contained in:
2026-03-04 00:32:11 +01:00
parent dcc81ec9bb
commit f8be8166b7
5 changed files with 253 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
<?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\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()),
);
$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());
}
}