Skip to content

Commit

Permalink
WB-623: test(InvokableBehaviorFakeTest): add test for behavior isolat…
Browse files Browse the repository at this point in the history
…ion after reset

Add a new test to ensure behavior isolation is maintained after resetting
all fakes. This test verifies that TestIncrementAction and TestCountGuard
fakes operate independently following a reset.
  • Loading branch information
deligoez committed Nov 5, 2024
1 parent 892c3cf commit c270c68
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/InvokableBehaviorFakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,18 @@ public function __invoke(ContextManager $context): bool
TestCountGuard::shouldRun()->never();
TestCountGuard::assertNotRan();
});
it('maintains behavior isolation after resetting all fakes', function (): void {
// 1. Arrange
TestIncrementAction::shouldRun()->once();
TestCountGuard::shouldRun()->twice();
EventMachine::resetAllFakes();

// 2. Act
TestIncrementAction::shouldRun()->once();
TestIncrementAction::run(new ContextManager(['count' => 0]));

// 3. Assert
TestIncrementAction::assertRan();
expect(TestCountGuard::isFaked())->toBeFalse();
});
// endregion

0 comments on commit c270c68

Please sign in to comment.