---
title: "Discussion on \"PHPUnit: Test Closures with Mockery::spy\" | Hashnode"
description: "Discussion on \"PHPUnit: Test Closures with Mockery::spy\". Assertions inside a closure pass silently even if never called. Wrap the closure in Mockery::spy to verify invocation count and arguments in PHPUnit tests."
url: "https://hashnode.com/posts/how-to-test-closure-in-phpunit-1/69add9793db07d80867ebed5"
---

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

Discussion

# [PHPUnit: Test Closures with Mockery::spy](https://recca0120.hashnode.dev/how-to-test-closure-in-phpunit-1?utm_source=hashnode&utm_medium=feed)

Assertions inside a closure pass silently even if never called. Wrap the closure in Mockery::spy to verify invocation count and arguments in PHPUnit tests.

Mar 8 · 1 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.
