candasm/hypno

Delay execution commands package which covers sleep, usleep, time_nanosleep and time_sleep_until functions. This package useful for unit tests.

1.0.0 2020-11-09 21:20 UTC

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.

Image of Hypno

Travis (.org) Coverage Status Packagist PHP Version Support

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+