candasm / hypno
Delay execution commands package which covers sleep, usleep, time_nanosleep and time_sleep_until functions. This package useful for unit tests.
Installs: 1 143
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.6
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-16 23:08:43 UTC
README
Hypno is a wrapper of PHP delay execution commands package.This package created to write less complex unit test when delaying methods used in the application logic.
Installation
$ composer require candasm/hypno
Basic Usage
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);
Unit Testing
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(); });
Documentation
You can check Hypnosis class to see how methods are working.
Requirements
PHP 5.6+