mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
- the workflow controller add a context to each transition; - the state of the entity workflow is applyied using a dedicated marking store - the method EntityWorkflow::step use the context to associate the new step with the future destination user, cc users and email. This makes the step consistent at every step. - this allow to remove some logic which was processed in eventSubscribers, - as counterpart, each workflow must specify a dedicated marking_store: ```yaml framework: workflows: vendee_internal: # ... marking_store: service: Chill\MainBundle\Workflow\EntityWorkflowMarkingStore ```
81 lines
2.4 KiB
PHP
81 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\MainBundle\Tests\Entity\Workflow;
|
|
|
|
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
|
use Chill\MainBundle\Workflow\WorkflowTransitionContextDTO;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* @internal
|
|
*
|
|
* @coversNothing
|
|
*/
|
|
final class EntityWorkflowTest extends TestCase
|
|
{
|
|
public function testIsFinalizeWith1Steps()
|
|
{
|
|
$entityWorkflow = new EntityWorkflow();
|
|
|
|
$entityWorkflow->setStep('final', new WorkflowTransitionContextDTO($entityWorkflow));
|
|
$entityWorkflow->getCurrentStep()->setIsFinal(true);
|
|
|
|
$this->assertTrue($entityWorkflow->isFinal());
|
|
}
|
|
|
|
public function testIsFinalizeWith4Steps()
|
|
{
|
|
$entityWorkflow = new EntityWorkflow();
|
|
|
|
$this->assertFalse($entityWorkflow->isFinal());
|
|
|
|
$entityWorkflow->setStep('two', new WorkflowTransitionContextDTO($entityWorkflow));
|
|
|
|
$this->assertFalse($entityWorkflow->isFinal());
|
|
|
|
$entityWorkflow->setStep('previous_final', new WorkflowTransitionContextDTO($entityWorkflow));
|
|
|
|
$this->assertFalse($entityWorkflow->isFinal());
|
|
|
|
$entityWorkflow->getCurrentStep()->setIsFinal(true);
|
|
$entityWorkflow->setStep('final', new WorkflowTransitionContextDTO($entityWorkflow));
|
|
|
|
$this->assertTrue($entityWorkflow->isFinal());
|
|
}
|
|
|
|
public function testIsFreeze()
|
|
{
|
|
$entityWorkflow = new EntityWorkflow();
|
|
|
|
$this->assertFalse($entityWorkflow->isFreeze());
|
|
|
|
$entityWorkflow->setStep('step_one', new WorkflowTransitionContextDTO($entityWorkflow));
|
|
|
|
$this->assertFalse($entityWorkflow->isFreeze());
|
|
|
|
$entityWorkflow->setStep('step_three', new WorkflowTransitionContextDTO($entityWorkflow));
|
|
|
|
$this->assertFalse($entityWorkflow->isFreeze());
|
|
|
|
$entityWorkflow->setStep('freezed', new WorkflowTransitionContextDTO($entityWorkflow));
|
|
$entityWorkflow->getCurrentStep()->setFreezeAfter(true);
|
|
|
|
$this->assertTrue($entityWorkflow->isFreeze());
|
|
|
|
$entityWorkflow->setStep('after_freeze', new WorkflowTransitionContextDTO($entityWorkflow));
|
|
|
|
$this->assertTrue($entityWorkflow->isFreeze());
|
|
|
|
$this->assertTrue($entityWorkflow->getCurrentStep()->isFreezeAfter());
|
|
}
|
|
}
|