Skip to content

candasm/hypno

Repository files navigation

Hypno (Delay execution package for PHP)

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+