StateMachineValidator example

class StateMachineValidatorTest extends TestCase
{
    public function testWithMultipleTransitionWithSameNameShareInput()
    {
        $this->expectException(InvalidDefinitionException::class);
        $this->expectExceptionMessage('A transition from a place/state must have an unique name.');
        $places = ['a', 'b', 'c'];
        $transitions[] = new Transition('t1', 'a', 'b');
        $transitions[] = new Transition('t1', 'a', 'c');
        $definition = new Definition($places$transitions);

        (new StateMachineValidator())->validate($definition, 'foo');

        // The graph looks like:         //         // +----+ +----+ +---+         // | a | --> | t1 | --> | b |         // +----+ +----+ +---+         // |         // |         // v         // +----+ +----+         // | t1 | --> | c |
$workflowDefinition->addTag('workflow.state_machine', ['name' => $name]);
            }

            // Store to container             $container->setDefinition($workflowId$workflowDefinition);
            $container->setDefinition(sprintf('%s.definition', $workflowId)$definitionDefinition);
            $container->registerAliasForArgument($workflowId, WorkflowInterface::class$name.'.'.$type);
            $container->registerAliasForArgument($workflowId, WorkflowInterface::class$name);

            // Validate Workflow             if ('state_machine' === $workflow['type']) {
                $validator = new Workflow\Validator\StateMachineValidator();
            } else {
                $validator = new Workflow\Validator\WorkflowValidator();
            }

            $trs = array_map(fn (Reference $ref): Workflow\Transition => $container->get((string) $ref)$transitions);
            $realDefinition = new Workflow\Definition($places$trs$initialMarking);
            $validator->validate($realDefinition$name);

            // Add workflow to Registry             if ($workflow['supports']) {
                foreach ($workflow['supports'] as $supportedClassName) {
                    
Home | Imprint | This part of the site doesn't use cookies.