PHPackages                             xp-framework/mocks - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. xp-framework/mocks

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xp-framework/mocks
==================

Mocks for the XP Framework

v8.0.1(4y ago)013.8k—3.3%BSD-3-ClausePHPPHP &gt;=7.0.0CI failing

Since Aug 6Pushed 4y ago1 watchersCompare

[ Source](https://github.com/xp-framework/mocks)[ Packagist](https://packagist.org/packages/xp-framework/mocks)[ Docs](http://xp-framework.net/)[ RSS](/packages/xp-framework-mocks/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (3)Versions (11)Used By (0)

Mocks
=====

[](#mocks)

[![Build status on GitHub](https://github.com/xp-framework/mocks/workflows/Tests/badge.svg)](https://github.com/xp-framework/mocks/actions)[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/68c5c37b89567f3f4c093dadf3b0b9a54ce4f6540a01c7bf86567f263c8947d5/68747470733a2f2f706f7365722e707567782e6f72672f78702d6672616d65776f726b2f6d6f636b732f76657273696f6e2e706e67)](https://packagist.org/packages/xp-framework/mocks)

Mocks for the XP Framework.

Example
-------

[](#example)

Here's an example implementation:

```
use lang\IllegalAccessException;

interface Context {
  public function hasPermission($name);
}

class UserService {
  private $context;

  public function __construct(Context $context) {
    $this->context= $context;
  }

  public function allUsers() {
    if (!$this->context->hasPermission('rt=all,rn=users')) {
      throw new IllegalAccessException('Permission denied!');
    }

    return []; // TODO: Actually do something:)
  }
}
```

This is how we can mock the `Context` interface:

```
use unittest\TestCase;

class UserServiceTest extends TestCase {

  #[@test]
  public function allUsers_works_when_hasPermission_returns_true() {
    $mocks= new MockRepository();
    $context= $mocks->createMock('Context');
    $context->hasPermission('rt=all,rn=users')->returns(true);
    $mocks->replayAll();

    $fixture= new UserService($context);
    $this->assertEquals([], $fixture->allUsers());
  }
}
```

Further reading
---------------

[](#further-reading)

See [XP RFC #0219](https://github.com/xp-framework/rfc/issues/219) for a detailled introduction.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 95.1% 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 ~266 days

Recently: every ~496 days

Total

10

Last Release

1589d ago

Major Versions

v6.6.1 → v7.0.02018-01-09

v7.0.1 → v8.0.02020-04-11

PHP version history (4 changes)v6.4.2PHP &gt;=5.4.0

v6.5.0PHP &gt;=5.5.0

v7.0.0PHP &gt;=5.6.0

v8.0.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/07d18d882c8b4aaf3466432f64018214f2771eda333202175431ee7233795376?d=identicon)[thekid](/maintainers/thekid)

---

Top Contributors

[![thekid](https://avatars.githubusercontent.com/u/696742?v=4)](https://github.com/thekid "thekid (39 commits)")[![beorgler](https://avatars.githubusercontent.com/u/2027220?v=4)](https://github.com/beorgler "beorgler (1 commits)")[![kiesel](https://avatars.githubusercontent.com/u/127769?v=4)](https://github.com/kiesel "kiesel (1 commits)")

---

Tags

mockphpunittestxp-frameworkmodulexp

### Embed Badge

![Health badge](/badges/xp-framework-mocks/health.svg)

```
[![Health](https://phpackages.com/badges/xp-framework-mocks/health.svg)](https://phpackages.com/packages/xp-framework-mocks)
```

PHPackages © 2026

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