Skip to content

Commit

Permalink
Fix running commands in old places while reducing steps
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed May 4, 2022
1 parent a3d9de4 commit d8c2bc2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Service/Step/Runner/ReduceStepsRunner.php
Expand Up @@ -50,6 +50,9 @@ protected function runStep(StepInterface $step, RevisionInterface $revision, Rem
$marking = $this->markingHelper->getMarking($this->petrinet, $step->getPlaces(), $step->getColor());
$transition = $this->petrinet->getTransitionById($step->getTransition());
if ($this->transitionService->isEnabled($transition, $marking)) {
$this->transitionService->fire($transition, $marking);
$step->setPlaces($this->markingHelper->getPlaces($marking));

return parent::runStep($step, $revision, $driver);
}

Expand Down
12 changes: 12 additions & 0 deletions tests/Service/Step/Runner/ReduceStepsRunnerTest.php
Expand Up @@ -106,6 +106,18 @@ protected function assertRunSteps(
array_slice($this->steps, 0, count($steps) + $nextStepDisabled)
))
->willReturnOnConsecutiveCalls(...[...array_fill(0, count($steps), true), !$nextStepDisabled]);
$this->transitionService
->expects($this->exactly(count($steps)))
->method('fire')
->withConsecutive(...array_map(
fn (StepInterface $step) => [$this->transitions[$step->getTransition()], $this->marking],
array_slice($this->steps, 0, count($steps))
));
$this->markingHelper
->expects($this->exactly(count($steps)))
->method('getPlaces')
->with($this->marking)
->willReturn([]);
} else {
$this->transitionService
->expects($this->exactly(count($this->steps)))
Expand Down

0 comments on commit d8c2bc2

Please sign in to comment.