PHPUnit: Mock sleep() in 2 Ways Without Waiting
When 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.
Tag archive
When 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.
Assertions inside a closure pass silently even if never called. Wrap the closure in Mockery::spy to verify invocation count and arguments in PHPUnit tests.
Mocking IteratorAggregate breaks foreach in PHPUnit. Return an ArrayObject from the mocked getIterator method to make foreach iterate over test data correctly.
When a method uses random_int internally, Mockery::capture with passthru captures the intermediate value so you can compute the expected result and assert it.

In modern unit testing, the clarity of your test code is just as important as the logic itself. For...
Иногда при работе с mock объектами библиотеки Mockery, мы хотим сообщить фейковому методу, чтобы он в...