mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
When a user applies a signature in a workflow, the signer is the futureDestUser of the next step
See: - Vendee/accent-suivi-developpement#1252 - https://champs-libres.openproject.com/wp/768 - OP#768
This commit is contained in:
parent
97729de66d
commit
bf85e9bb71
@ -37,7 +37,7 @@ use Symfony\Component\Workflow\WorkflowInterface;
|
|||||||
*/
|
*/
|
||||||
class SignatureStepStateChangerTest extends TestCase
|
class SignatureStepStateChangerTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testMarkSignatureAsSignedScenarioWhichExpectsTransition()
|
public function testMarkSignatureAsSignedScenarioWhichExpectsTransitionSignatureWithPerson()
|
||||||
{
|
{
|
||||||
$entityWorkflow = new EntityWorkflow();
|
$entityWorkflow = new EntityWorkflow();
|
||||||
$entityWorkflow->setWorkflowName('dummy');
|
$entityWorkflow->setWorkflowName('dummy');
|
||||||
@ -84,6 +84,40 @@ class SignatureStepStateChangerTest extends TestCase
|
|||||||
self::assertNotNull($signatures[1]->getStateDate());
|
self::assertNotNull($signatures[1]->getStateDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMarkSignatureAsSignedScenarioWhichExpectsTransitionSignatureWithUser()
|
||||||
|
{
|
||||||
|
$entityWorkflow = new EntityWorkflow();
|
||||||
|
$entityWorkflow->setWorkflowName('dummy');
|
||||||
|
$registry = $this->buildRegistry();
|
||||||
|
$workflow = $registry->get($entityWorkflow, 'dummy');
|
||||||
|
$clock = new MockClock();
|
||||||
|
$user = new User();
|
||||||
|
|
||||||
|
$messengerBus = new MessageBus([]);
|
||||||
|
$changer = new SignatureStepStateChanger($registry, $clock, new NullLogger(), $messengerBus);
|
||||||
|
|
||||||
|
// move it to signature
|
||||||
|
$dto = new WorkflowTransitionContextDTO($entityWorkflow);
|
||||||
|
$dto->futureUserSignature = $signer = new User();
|
||||||
|
$workflow->apply($entityWorkflow, 'to_signature', ['context' => $dto, 'transitionAt' => $clock->now(),
|
||||||
|
'byUser' => $user, 'transition' => 'to_signature']);
|
||||||
|
|
||||||
|
// get the signature created
|
||||||
|
$signatures = $entityWorkflow->getCurrentStep()->getSignatures();
|
||||||
|
|
||||||
|
// 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(EntityWorkflowSignatureStateEnum::SIGNED, $signatures[0]->getState());
|
||||||
|
self::assertEquals('post-signature', $entityWorkflow->getStep(), 'the entity workflow step should be post-signature');
|
||||||
|
self::assertContains($signer, $entityWorkflow->getCurrentStep()->getAllDestUser());
|
||||||
|
self::assertCount(1, $entityWorkflow->getCurrentStep()->getAllDestUser());
|
||||||
|
self::assertEquals(1, $signatures[0]->getZoneSignatureIndex());
|
||||||
|
self::assertNotNull($signatures[0]->getStateDate());
|
||||||
|
}
|
||||||
|
|
||||||
public function testMarkSignatureAsSignedScenarioWithoutRequiredMetadata()
|
public function testMarkSignatureAsSignedScenarioWithoutRequiredMetadata()
|
||||||
{
|
{
|
||||||
$entityWorkflow = new EntityWorkflow();
|
$entityWorkflow = new EntityWorkflow();
|
||||||
|
@ -97,16 +97,20 @@ class SignatureStepStateChanger
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$previousUser = $this->getPreviousSender($signature->getStep());
|
if ('person' === $signature->getSignerKind()) {
|
||||||
|
$futureUser = $this->getPreviousSender($signature->getStep());
|
||||||
|
} else {
|
||||||
|
$futureUser = $signature->getSigner();
|
||||||
|
}
|
||||||
|
|
||||||
if (null === $previousUser) {
|
if (null === $futureUser) {
|
||||||
$this->logger->info(self::LOG_PREFIX.'No previous user, will not apply a transition', ['signatureId' => $signature->getId()]);
|
$this->logger->info(self::LOG_PREFIX.'No previous user, will not apply a transition', ['signatureId' => $signature->getId()]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$transitionDto = new WorkflowTransitionContextDTO($entityWorkflow);
|
$transitionDto = new WorkflowTransitionContextDTO($entityWorkflow);
|
||||||
$transitionDto->futureDestUsers[] = $previousUser;
|
$transitionDto->futureDestUsers[] = $futureUser;
|
||||||
|
|
||||||
$workflow->apply($entityWorkflow, $transition, [
|
$workflow->apply($entityWorkflow, $transition, [
|
||||||
'context' => $transitionDto,
|
'context' => $transitionDto,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user