From c270c68ecc53571764b08ef6b8cb5a18428d2f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yunus=20Emre=20Delig=C3=B6z?= Date: Tue, 5 Nov 2024 20:29:24 +0300 Subject: [PATCH] WB-623: test(InvokableBehaviorFakeTest): add test for behavior isolation 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. --- tests/InvokableBehaviorFakeTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/InvokableBehaviorFakeTest.php b/tests/InvokableBehaviorFakeTest.php index e2508c6..14762c9 100644 --- a/tests/InvokableBehaviorFakeTest.php +++ b/tests/InvokableBehaviorFakeTest.php @@ -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