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.5(1mo ago)037MITPHPPHP ^8.4CI passing

Since Dec 18Pushed 1mo agoCompare

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

READMEChangelog (10)Dependencies (25)Versions (39)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!](./docs/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

43

—

FairBetter than 89% of packages

Maintenance93

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

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

Total

26

Last Release

35d 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 (138 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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