项目作者: candasm

项目描述 :
Delay execution package for PHP
高级语言: PHP
项目地址: git://github.com/candasm/hypno.git
创建时间: 2020-11-09T21:13:29Z
项目社区:https://github.com/candasm/hypno

开源协议:MIT License

下载


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

  1. $ 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.

  1. <?php
  2. use Candasm\Hypno;
  3. $hypno = new Hypno\Hypnosis();
  4. $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.

  1. <?php
  2. use Candasm\Hypno;
  3. $hypno = \Mockery::mock(Hypno\Hypnotize::class, function(\Mockery\MockInterface $m) {
  4. $m->shouldReceive('sleep')->with(1)->returnNull();
  5. });

Documentation

You can check Hypnosis class to see how methods are working.

Requirements

PHP 5.6+