PHPackages                             driade/sleepery - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. driade/sleepery

ActiveLibrary[Testing &amp; Quality](/categories/testing)

driade/sleepery
===============

sleep and usleep wrappers to make them easier to test

1.0.2(3y ago)213MITPHP

Since Feb 21Pushed 3y ago1 watchersCompare

[ Source](https://github.com/driade/sleepery)[ Packagist](https://packagist.org/packages/driade/sleepery)[ Docs](https://github.com/driade/sleepery)[ RSS](/packages/driade-sleepery/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (4)Used By (0)

PHP wrapper for the sleep() and usleep() functions for easy testing
===================================================================

[](#php-wrapper-for-the-sleep-and-usleep-functions-for-easy-testing)

[![Packagist](https://camo.githubusercontent.com/f5a811c253eb4959eaa5f3b8a278f93597e8a844f9b12c11ae678db1f8fb8de1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6472696164652f736c6565706572792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/driade/sleepery)[![Tests](https://camo.githubusercontent.com/8de00dffcd3a009fac2699c5a30b7711d246bdf8307798761650724db85bff2e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6472696164652f736c6565706572792f6769746875622e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/driade/sleepery/actions/workflows/github.yml)[![Downloads](https://camo.githubusercontent.com/9ecb192563a92e32a01575e24e95a66110ea2c7274e4effd23c5e75d3131ce80/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6472696164652f736c6565706572792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/driade/sleepery)

This package allows you to easily test the sleep() and usleep() functions without having to "wait".

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require driade/sleepery
```

Usage
-----

[](#usage)

Instead of using sleep() in your code you should use

```
Driade\Sleepery::dream(1);
```

and, instead of using usleep() in your code you should use

```
Driade\Sleepery::nap(1000);
```

When it comes to test your code, you can use the "fake" function to make the calls to dream() and nap() recorded, so you can later test them.

In your tests

```
use Driade\Sleepery;

Sleepery::fake();

(new PerformAction)->handle(); // execute your code

Sleepery::wakeup();

//

Sleepery::assertDreamt(1);
Sleepery::assertNapped(1000);
```

You may also use the following functions

```
Sleepery::assertNeverDreamt(); // no call to sleep() was made
```

```
Sleepery::assertNeverNapped(); // no call to usleep() was made
```

```
Sleepery::getDreams(); // returns all the dream() calls while dreaming
```

```
Sleepery::getNaps(); // returns all the nap() calls while dreaming
```

```
Sleepery::wakeup(); // stop dreaming
```

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please feel free to open an issue or pull request if you think something can be improved

Credits
-------

[](#credits)

- [David Fernández](https://github.com/driade)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

1181d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bee87b1178721a08c5b5a4bf1734792fc8330106b01a6370e36b416696bfba18?d=identicon)[driade](/maintainers/driade)

---

Top Contributors

[![driade](https://avatars.githubusercontent.com/u/5692232?v=4)](https://github.com/driade "driade (4 commits)")

---

Tags

phptesting

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/driade-sleepery/health.svg)

```
[![Health](https://phpackages.com/badges/driade-sleepery/health.svg)](https://phpackages.com/packages/driade-sleepery)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
