mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 16:13:50 +00:00
Add async handling for signature state changes
Introduce MessageBus to handle post-signature operations asynchronously. This ensures that further steps are executed through dispatched messages, improving system scalability and performance. Implement new handlers and messages for the workflow state transitions.
This commit is contained in:
@@ -21,6 +21,7 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\NullLogger;
|
||||
use Symfony\Component\Clock\MockClock;
|
||||
use Symfony\Component\Messenger\MessageBus;
|
||||
use Symfony\Component\Workflow\DefinitionBuilder;
|
||||
use Symfony\Component\Workflow\Metadata\InMemoryMetadataStore;
|
||||
use Symfony\Component\Workflow\Registry;
|
||||
@@ -44,7 +45,9 @@ class SignatureStepStateChangerTest extends TestCase
|
||||
$workflow = $registry->get($entityWorkflow, 'dummy');
|
||||
$clock = new MockClock();
|
||||
$user = new User();
|
||||
$changer = new SignatureStepStateChanger($registry, $clock, new NullLogger());
|
||||
|
||||
$messengerBus = new MessageBus([]);
|
||||
$changer = new SignatureStepStateChanger($registry, $clock, new NullLogger(), $messengerBus);
|
||||
|
||||
// move it to signature
|
||||
$dto = new WorkflowTransitionContextDTO($entityWorkflow);
|
||||
@@ -61,6 +64,8 @@ class SignatureStepStateChangerTest extends TestCase
|
||||
|
||||
// we mark the first signature as signed
|
||||
$changer->markSignatureAsSigned($signatures[0], 1);
|
||||
// the next step should be done by handling an async message
|
||||
$changer->onPostMark($signatures[0]);
|
||||
|
||||
self::assertEquals('signature', $entityWorkflow->getStep(), 'there should have any change in the entity workflow step');
|
||||
self::assertEquals(EntityWorkflowSignatureStateEnum::SIGNED, $signatures[0]->getState());
|
||||
@@ -70,6 +75,8 @@ class SignatureStepStateChangerTest extends TestCase
|
||||
|
||||
// we mark the second signature as signed
|
||||
$changer->markSignatureAsSigned($signatures[1], 2);
|
||||
// the next step should be done by handling an async message
|
||||
$changer->onPostMark($signatures[1]);
|
||||
self::assertEquals(EntityWorkflowSignatureStateEnum::SIGNED, $signatures[1]->getState());
|
||||
self::assertEquals('post-signature', $entityWorkflow->getStep(), 'the entity workflow step should be post-signature');
|
||||
self::assertContains($user, $entityWorkflow->getCurrentStep()->getAllDestUser());
|
||||
@@ -85,7 +92,7 @@ class SignatureStepStateChangerTest extends TestCase
|
||||
$workflow = $registry->get($entityWorkflow, 'dummy');
|
||||
$clock = new MockClock();
|
||||
$user = new User();
|
||||
$changer = new SignatureStepStateChanger($registry, $clock, new NullLogger());
|
||||
$changer = new SignatureStepStateChanger($registry, $clock, new NullLogger(), new MessageBus([]));
|
||||
|
||||
// move it to signature
|
||||
$dto = new WorkflowTransitionContextDTO($entityWorkflow);
|
||||
@@ -102,6 +109,8 @@ class SignatureStepStateChangerTest extends TestCase
|
||||
|
||||
// we mark the first signature as signed
|
||||
$changer->markSignatureAsSigned($signatures[0], 1);
|
||||
// the next step should be done by handling an async message
|
||||
$changer->onPostMark($signatures[0]);
|
||||
|
||||
self::assertEquals('signature-without-metadata', $entityWorkflow->getStep(), 'there should have any change in the entity workflow step');
|
||||
self::assertEquals(EntityWorkflowSignatureStateEnum::SIGNED, $signatures[0]->getState());
|
||||
|
Reference in New Issue
Block a user