Skip to content

Commit

Permalink
WB-707: test(resolveinlinebehaviortest): add tests for missing behaviors
Browse files Browse the repository at this point in the history
Add tests to verify exceptions are thrown when behaviors are not found.
These tests ensure that `OrderMachine` correctly handles missing behavior types.
  • Loading branch information
deligoez committed Nov 19, 2024
1 parent 1841515 commit f40f51a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/ResolveInlineBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,18 @@
expect($eventBehavior)->toBeInstanceOf(EventBehavior::class)
->and($eventBehavior::getType())->toBe('ORDER_CREATED');
});

test('it throws exception when behavior not found', function (): void {
expect(fn () => OrderMachine::getCalculator('nonExistentCalculator'))
->toThrow(BehaviorNotFoundException::class, 'Behavior of type `calculators.nonExistentCalculator` not found.');

expect(fn () => OrderMachine::getGuard('nonExistentGuard'))
->toThrow(BehaviorNotFoundException::class, 'Behavior of type `guards.nonExistentGuard` not found.');

expect(fn () => OrderMachine::getAction('nonExistentAction'))
->toThrow(BehaviorNotFoundException::class, 'Behavior of type `actions.nonExistentAction` not found.');

expect(fn () => OrderMachine::getEvent('nonExistentEvent'))
->toThrow(BehaviorNotFoundException::class, 'Behavior of type `events.nonExistentEvent` not found.');
});

0 comments on commit f40f51a

Please sign in to comment.