---
title: "Discussion on \"PHPUnit: Mock sleep() in 2 Ways Without Waiting\" | Hashnode"
description: "Discussion on \"PHPUnit: Mock sleep() in 2 Ways Without Waiting\". When sleep() slows PHPUnit tests, extract a Clock class and use Mockery spy to replace it, or use php-mock to mock the built-in function with no code changes."
url: "https://hashnode.com/posts/phpunit-sleep-1/69add9aabc4378bf8e67b28f"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [PHPUnit: Mock sleep() in 2 Ways Without Waiting](https://recca0120.hashnode.dev/phpunit-sleep-1?utm_source=hashnode&utm_medium=feed)

When sleep() slows PHPUnit tests, extract a Clock class and use Mockery spy to replace it, or use php-mock to mock the built-in function with no code changes.

Mar 8 · 2 min read · recca0120.hashnode.dev  
Read the article

-   [#mockery](https://hashnode.com/tag/mockery)
-   [#php](https://hashnode.com/tag/php)
-   [#phpunit](https://hashnode.com/tag/phpunit)
-   [#testing](https://hashnode.com/tag/testing)

## Written by

[recca0120](https://hashnode.com/@recca0120)

@recca0120 · Taipei, Taiwan

  
[View profile](https://hashnode.com/@recca0120)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
