Rrecca0120·Mar 8PHPUnit: Mock sleep() in 2 Ways Without WaitingWhen sleep() slows PHPUnit tests, extract a Clock class and use Mockery spy to replace it, or use php-mock to mock the built-in function with no code changes.2 min read·recca0120.hashnode.dev
Rrecca0120·Mar 8PHPUnit: Test Closures with Mockery::spyAssertions inside a closure pass silently even if never called. Wrap the closure in Mockery::spy to verify invocation count and arguments in PHPUnit tests.1 min read·recca0120.hashnode.dev
Rrecca0120·Mar 3Write Deterministic PHPUnit Assertions with Mockery::captureWhen a method uses random_int internally, Mockery::capture with passthru captures the intermediate value so you can compute the expected result and assert it.2 min read·recca0120.hashnode.dev
Rrecca0120·Mar 3Mock IteratorAggregate with Mockery to Fix foreach in TestsMocking IteratorAggregate breaks foreach in PHPUnit. Return an ArrayObject from the mocked getIterator method to make foreach iterate over test data correctly.1 min read·recca0120.hashnode.dev
BBedram Tamang·Mar 31, 2023Test Doubles in PHP with Mockery and PHPUnitTest doubles is a technique in which you replace the actual object with pretend object or a real method by pretend method or pre-define the return data and function arguments for a method to ease the testing purpose. In the real world, our applicatio...5 min read·blog.jobins.jp1N