Description
Symfony version(s) affected
all
Description
The behavior of transitions depends on the order in which they are declared.
How to reproduce
private static function createWorkflowWithSameNameBackTransition(): Definition
{
$places = range('a', 'c');
$transitions = [];
$transitions[] = new Transition('a_to_bc', 'a', ['b', 'c']);
$transitions[] = new Transition('back1', 'b', 'a');
$transitions[] = new Transition('back1', 'c', 'b');
$transitions[] = new Transition('back2', 'c', 'b');
$transitions[] = new Transition('back2', 'b', 'a');
return new Definition($places, $transitions);
// The graph looks like:
// +--------+
// +---| back_N |<------+ +-----------------+
// | +--------+ | | |
// v | v |
// +---+ +---------+ +---+ +---+ +--------+
// | a | -> | a_to_bc | | b | | c | --> | back_N |
// +---+ +---------+ +---+ +---+ +--------+
// | ^ ^
// +--------+------+
}
public static function backVariants()
{
return [['back1'], ['back2']];
}
/**
* @dataProvider backVariants
*/
public function testApplyWithSameNameBackTransition($transition)
{
$subject = new Subject();
$definition = $this->createWorkflowWithSameNameBackTransition();
$workflow = new Workflow($definition, new MethodMarkingStore());
$marking = $workflow->apply($subject, 'a_to_bc');
$this->assertFalse($marking->has('a'));
$this->assertTrue($marking->has('b'));
$this->assertTrue($marking->has('c'));
$marking = $workflow->apply($subject, $transition);
$this->assertTrue($marking->has('a'));
$this->assertTrue($marking->has('b'));
$this->assertFalse($marking->has('c'));
}
Possible Solution
No response
Additional Context
No response