Skip to content

Commit

Permalink
Merge pull request #66 from tarfin-labs/WEB-4061-test-senaryo-datalar…
Browse files Browse the repository at this point in the history
…inin-v-4-te-kullanilabilir-olmasinin-saglanmasi
  • Loading branch information
deligoez authored Nov 20, 2023
2 parents 1322d0e + 35237a5 commit 65a7c67
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/Definition/MachineDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ public function transition(

// Get scenario state if exists
$newState = $this->getScenarioStateIfAvailable(state: $newState, eventBehavior: $eventBehavior);
if ($state->currentStateDefinition->id !== $newState->currentStateDefinition->id) {
$targetStateDefinition = $newState->currentStateDefinition;
}

// Record state enter event
$state->setInternalEventBehavior(
Expand Down
4 changes: 2 additions & 2 deletions tests/ScenarioTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
expect($state)
->toBeInstanceOf(State::class)
->and($state->value)->toBe([MachineDefinition::DEFAULT_ID.MachineDefinition::STATE_DELIMITER.'test.stateC'])
->and($state->context->count)->toBe(0);
->and($state->context->count)->toBe(-1);

$state = $machine->send('EVENT_D');

expect($state)
->toBeInstanceOf(State::class)
->and($state->value)->toBe([MachineDefinition::DEFAULT_ID.MachineDefinition::STATE_DELIMITER.'test.stateA'])
->and($state->context->count)->toBe(-1);
->and($state->context->count)->toBe(-2);
});
3 changes: 3 additions & 0 deletions tests/Stubs/Machines/MachineWithScenarios.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public static function definition(): MachineDefinition
],
],
'stateC' => [
'entry' => [
'decrementAction',
],
'on' => [
'EVENT_D' => [
'target' => 'stateA',
Expand Down

0 comments on commit 65a7c67

Please sign in to comment.