PHPackages                             knutle/pest-mock-recorder - 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. knutle/pest-mock-recorder

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

knutle/pest-mock-recorder
=========================

Lets you easily bind a mock to the service container that can flexibly record history every time it is used

v0.1.2(3y ago)093[3 PRs](https://github.com/knutle/pest-mock-recorder/pulls)MITPHPPHP ^8.0

Since May 31Pushed 2y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (15)Versions (7)Used By (0)

[![](https://camo.githubusercontent.com/2bedf63f24cda7efab02da955dc11fb7ef8a060e2f26b73c33a7aac84529b8a3/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f737570706f72742d756b7261696e652e7376673f743d31)](https://supportukrainenow.org)

[![Latest Version on Packagist](https://camo.githubusercontent.com/97db689b312f8f75d5853c3d231e8c2eae4de355794042ef4472480d68f8e612/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6e75746c652f706573742d6d6f636b2d7265636f726465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/knutle/pest-mock-recorder)[![GitHub Tests Action Status](https://camo.githubusercontent.com/b3fd5e833841203038c9198bd4171dd24404e0b4856d64e1c69094788ac78147/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6b6e75746c652f706573742d6d6f636b2d7265636f726465722f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/knutle/pest-mock-recorder/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/62f8d4c59aad752e844de747bfdbe7b02dae5f579ab29a6b3804946b144c459a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6b6e75746c652f706573742d6d6f636b2d7265636f726465722f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/knutle/pest-mock-recorder/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/55f0c5ff12ec840b636722865993452697b0a403017891fd2742d00c3e103c9e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6e75746c652f706573742d6d6f636b2d7265636f726465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/knutle/pest-mock-recorder)

Lets you easily bind a mock to the service container that can flexibly record details every time it is used. Especially helpful for generating a list of specific actions and their parameters throughout a job, then using that to match a snapshot or ensure that a certain sequence of actions happened in the right order.

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

[](#installation)

You can install the package via composer:

```
composer require knutle/pest-mock-recorder
```

Usage
-----

[](#usage)

```
# Automatically bind the mock to the service container while instantiating it
$mock = MockRecorder::bind(MyClass::class);

# Setup expectations for only recording
$mock->expect(
    write: fn (string $name) => $name
);

# Resolve your mock from the service container and watch the history fill up
app(MyClass::class)->write('Write 1'); // returns null
app(MyClass::class)->write('Write 2'); // returns null

# Both entries can now be found in the history variable
$mock->history == [
    'Write 1',
    'Write 2'
]

# You can also return an array to also return data from your mock
$mock->expect(
    write: fn (string $name) => [ $name, "Hello $name!" ]
);

app(MyClass::class)->write('Bob'); // returns "Hello Bob!"

# Still it records to history
$mock->history == [
    'Write 1',
    'Write 2',
    'Bob',
]
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Knut Leborg](https://github.com/knutle)
- [All Contributors](../../contributors)

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

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.6% 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 ~2 days

Total

3

Last Release

1437d ago

PHP version history (2 changes)v0.1.0PHP ^8.1

v0.1.1PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8712465c0072cf9165361e9de1be00199befd6e3fdc7097cf6217fc20d9dfc3e?d=identicon)[knutle](/maintainers/knutle)

---

Top Contributors

[![knutle](https://avatars.githubusercontent.com/u/1419066?v=4)](https://github.com/knutle "knutle (19 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")

---

Tags

laravelknutlepest-mock-recorder

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/knutle-pest-mock-recorder/health.svg)

```
[![Health](https://phpackages.com/badges/knutle-pest-mock-recorder/health.svg)](https://phpackages.com/packages/knutle-pest-mock-recorder)
```

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-visit

Quickly visit any route of your Laravel app

15614.6k](/packages/spatie-laravel-visit)[christophrumpel/missing-livewire-assertions

This package adds missing livewire test assertions.

149336.0k9](/packages/christophrumpel-missing-livewire-assertions)[michiruf/laravel-http-automock

Automatically mock http requests when testing

161.0k](/packages/michiruf-laravel-http-automock)

PHPackages © 2026

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