PHPackages                             exan/moock - 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. exan/moock

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

exan/moock
==========

Modern class mocking package

0.2.2(1w ago)036MITPHPCI passing

Since Dec 18Pushed 3w agoCompare

[ Source](https://github.com/Exanlv/moock)[ Packagist](https://packagist.org/packages/exan/moock)[ RSS](/packages/exan-moock/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (15)Versions (32)Used By (0)

Moock
=====

[](#moock)

 [![Moock logo](moock.png)](moock.png)
 A simple way of mocking objects in PHP

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

[](#installation)

```
composer require exan/moock
```

About
-----

[](#about)

Moock is a package to abstract creating test dummies for objects, intended to be used in unit tests. Using test dummies allows you to write more specific tests, where you don't have to worry about a class's dependencies. This works best when using the Dependency Injection pattern.

Check out the docs [here!](./documentation.md)

### Sales pitch

[](#sales-pitch)

If you're looking into this library, there's a good chance you already know of some other mocking library. (If not, see the [new to mocking](./new-to-mocking.md) introduction) For Moock, the goal is to rely on PHP language tricks as much as possible for the syntax.

Take for example the mocking of methods:

```
/** @var MyClass */
$myMock;

Mock::method($myMock->someMethod(...));
```

This makes it so IDE's don't (or shouldn't) need specific extensions to get nice auto-complete, or to support refactoring method names.

If you go ahead and rename `someMethod` on `MyClass`, your IDE will properly recognize it in your creation of mocks, and thus also rename it there.

Compare this to a fictional example:

```
/** @var MyClass */
$myMock;

$myMock->mockMethod('someMethod');
```

To get an IDE to automatically refactor `someMethod`, your IDE needs to be aware of PHP's syntax rules *and* the syntax of the package. Rather than only needing to know PHP syntax.

This can be achieved by having extensions specific to your IDE &amp; mocking library of choice, of course. Relying on these specific types of extensions however, is not my personal preference.

### Conscious omissions

[](#conscious-omissions)

There are some features you may take for granted in other libraries, including but not limited to:

- Overloading
- Mocking protected/private methods
- Mocking static methods

These are (opinionated) conscious omissions. These features can lead you down a path of hard to maintain tests, or tests which don't meaningfully test your application.

If you are missing a feature, please consider the above. If you don't think it applies, please create an issue with your request.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance96

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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 ~8 days

Recently: every ~22 days

Total

23

Last Release

8d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/50845695?v=4)[exan](/maintainers/exan)[@exan](https://github.com/exan)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/exan-moock/health.svg)

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

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14429.2M361](/packages/dms-phpunit-arraysubset-asserts)

PHPackages © 2026

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