This package created to write less complex unit test when delaying methods used in the application logic.
$ composer require candasm/hypno
Package covers sleep, usleep, time_nanosleep and time_sleep_until functions. Camelcased methods can be seen on Hypnotize interface.
<?php
use Candasm\Hypno;
$hypno = new Hypno\Hypnosis();
$hypno->sleep(5);
When you use your DI just inject Hypnotize interface then you can do this easily with Mockery or any other mock library.
<?php
use Candasm\Hypno;
$hypno = \Mockery::mock(Hypno\Hypnotize::class, function(\Mockery\MockInterface $m) {
$m->shouldReceive('sleep')->with(1)->returnNull();
});
You can check Hypnosis class to see how methods are working.
PHP 5.6+