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
This commit is contained in:
36
tests/Unit/Shared/IdempotencyTest.php
Normal file
36
tests/Unit/Shared/IdempotencyTest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MiniShop\Tests\Unit\Shared;
|
||||
|
||||
use MiniShop\Shared\Technical\InMemoryIdempotencyStore;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class IdempotencyTest extends TestCase
|
||||
{
|
||||
public function test_first_call_is_not_duplicate(): void
|
||||
{
|
||||
$store = new InMemoryIdempotencyStore();
|
||||
|
||||
self::assertFalse($store->isDuplicate('key-1'));
|
||||
}
|
||||
|
||||
public function test_second_call_is_duplicate(): void
|
||||
{
|
||||
$store = new InMemoryIdempotencyStore();
|
||||
|
||||
$store->isDuplicate('key-1');
|
||||
|
||||
self::assertTrue($store->isDuplicate('key-1'));
|
||||
}
|
||||
|
||||
public function test_different_keys_are_independent(): void
|
||||
{
|
||||
$store = new InMemoryIdempotencyStore();
|
||||
|
||||
$store->isDuplicate('key-1');
|
||||
|
||||
self::assertFalse($store->isDuplicate('key-2'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user