PHPackages                             holgerk/mockery-simple-mock - 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. holgerk/mockery-simple-mock

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

holgerk/mockery-simple-mock
===========================

Simple mock helper for Mockery

v1.0.1(2mo ago)0127MITPHPPHP &gt;=8.1CI passing

Since Mar 2Pushed 2mo agoCompare

[ Source](https://github.com/holgerk/mockery-simple-mock)[ Packagist](https://packagist.org/packages/holgerk/mockery-simple-mock)[ RSS](/packages/holgerk-mockery-simple-mock/feed)WikiDiscussions main Synced 1mo ago

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

mockery-simple-mock
===================

[](#mockery-simple-mock)

[![Tests](https://github.com/holgerk/mockery-simple-mock/actions/workflows/tests.yml/badge.svg)](https://github.com/holgerk/mockery-simple-mock/actions/workflows/tests.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/7a53a6d006ba0aff28363e29cd010e38d96d5ee8404ea364d78158afe559a471/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f686f6c6765726b2f6d6f636b6572792d73696d706c652d6d6f636b2e737667)](https://packagist.org/packages/holgerk/mockery-simple-mock)[![PHP Version](https://camo.githubusercontent.com/ad218ab63d4dae465bdfbaface0e0ca4e1051c3eb1d2f661ff85fcfde379987b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f686f6c6765726b2f6d6f636b6572792d73696d706c652d6d6f636b2e737667)](https://packagist.org/packages/holgerk/mockery-simple-mock)[![License](https://camo.githubusercontent.com/382c5781d66958efb56802626b9ff56909c638fb6949fc3d6263a243c37a0ab5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f686f6c6765726b2f6d6f636b6572792d73696d706c652d6d6f636b2e737667)](https://packagist.org/packages/holgerk/mockery-simple-mock)

A single helper function that wraps [Mockery](https://github.com/mockery/mockery) to make mocking and call capturing straightforward.

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

[](#installation)

```
composer require holgerk/mockery-simple-mock
```

Usage
-----

[](#usage)

```
use function Holgerk\MockerySimpleMock\simpleMock;
```

### Basic mock

[](#basic-mock)

```
$mock = simpleMock(MyService::class);
```

### Capture calls

[](#capture-calls)

Pass a variable by reference to collect every call made to any public method, keyed by method name and then by parameter name:

```
$mock = simpleMock(MyService::class, $capturedCalls);

$mock->greet('Alice', 42);

// $capturedCalls['greet'] === [['name' => 'Alice', 'age' => 42]]
```

Multiple calls to the same method are appended in order:

```
$mock->greet('Alice', 1);
$mock->greet('Bob', 2);

// $capturedCalls['greet'] === [
//     ['name' => 'Alice', 'age' => 1],
//     ['name' => 'Bob', 'age' => 2],
// ]
```

### Asserting calls with assertEquals

[](#asserting-calls-with-assertequals)

A key advantage of captured calls over traditional mock expectations is that `assertEquals` shows you a full diff between what you expected and what actually happened. With expectation-style assertions you typically only learn that a call was wrong; with captured calls you see exactly which argument differed and by how much.

```
$mock = simpleMock(MyService::class, $capturedCalls);

$mock->greet('Alice', 42);
$mock->greet('Bob', 7);

assertEquals([
    ['name' => 'Alice', 'age' => 42],
    ['name' => 'Bob',   'age' => 7],
], $capturedCalls['greet']);
```

> **Tip:** Writing out the expected array by hand can be tedious. My [holgerk/assert-golden](https://github.com/holgerk/assert-golden) package removes that step by recording the actual value directly into your source code on the first run, turning it into the expectation automatically.

When a call is wrong, PHPUnit prints a structured diff like:

```
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 [
     ['name' => 'Alice', 'age' => 42],
-    ['name' => 'Bob', 'age' => 7],
+    ['name' => 'Bob', 'age' => 99],
 ]

```

### Configure return values

[](#configure-return-values)

Pass an array of `methodName => returnValue` pairs as the third argument:

```
$mock = simpleMock(MyService::class, $capturedCalls, [
    'greet' => 'Hello, Alice!',
]);

$result = $mock->greet('Alice', 42); // 'Hello, Alice!'
```

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- mockery/mockery &gt;= 1.5

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance86

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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

2

Last Release

69d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8e55c03dc164181c5860898403302c95e31822e3610dc02027b1adc89269180d?d=identicon)[holgerk](/maintainers/holgerk)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/holgerk-mockery-simple-mock/health.svg)

```
[![Health](https://phpackages.com/badges/holgerk-mockery-simple-mock/health.svg)](https://phpackages.com/packages/holgerk-mockery-simple-mock)
```

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[jasonmccreary/laravel-test-assertions

A set of helpful assertions when testing Laravel applications.

3513.9M32](/packages/jasonmccreary-laravel-test-assertions)[brain/monkey

Mocking utility for PHP functions and WordPress plugin API

33412.5M350](/packages/brain-monkey)[codeception/mockery-module

Mockery Module for Codeception

344.2M82](/packages/codeception-mockery-module)[lastzero/test-tools

Increases testing productivity by adding a service container and self-initializing fakes to PHPUnit

2244.3k13](/packages/lastzero-test-tools)

PHPackages © 2026

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