PHPackages                             jeroendelau/mockolate - 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. jeroendelau/mockolate

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

jeroendelau/mockolate
=====================

05ActionScript

Since Jun 6Pushed 9y ago1 watchersCompare

[ Source](https://github.com/jeroendelau/mockolate)[ Packagist](https://packagist.org/packages/jeroendelau/mockolate)[ RSS](/packages/jeroendelau-mockolate/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Mockolate.
==========

[](#mockolate)

fake chocolate, mock objects and test spies.
============================================

[](#fake-chocolate-mock-objects-and-test-spies)

[mockolate.org](http://mockolate.org/) Documentation, examples, elaboration. [Drew Bourne](mailto:drew@firstbourne.com) Contact.

This tagline is probably a hint that Mockolate is most useful when testing software. Whether you are doing *test-driven-development*, *post-crunch-time fill-in-the-gaps*, or *exploratory-I-have-no-idea-what-is-going-on* testing Mockolate can help.

Mock Objects
============

[](#mock-objects)

A mock object can be used to simulate the behaviour of complex, real (non-mock) objects when using the real object would be impractical or impossible. Situations where a mock object would be useful:

- When an object is slow (like a database or webservice),
- is non-deterministic (like the current time),
- has states that are difficult to reproduce (like network connections)

The above is mostly appropriated from [Mock Objects at Wikipedia](http://en.wikipedia.org/wiki/Mock_object). I could keep rewriting it here, but it's really quite a good read.

Test Spies
==========

[](#test-spies)

In espionage, spies infiltrate a system, recording and relaying information to their handlers. The handlers may use that information to check facts, inform others, or take action.

In testing, a Test Spy records which methods are called, which getters are got, which setters are set. The handler (typically a testcase) can then check the facts against what should or should not have happened and take action (typically an assertion).

Mockolate?
==========

[](#mockolate-1)

- clean consistent syntax
- expectation-based or record-replay
- dynamically generates proxy Classes
- supports handcoded proxy Classes
- provides a FlexUnit 4 Rule and Runner
- uses proven libraries, [FlexUnit 4](http://flexunit.org/), [FLoxy](http://code.google.com/p/floxy) and [Hamcrest-as3](http://github.com/drewbourne/hamcrest-as3)

Next
====

[](#next)

Head over to  for documentation and examples:

- [Mockolate?](http://mockolate.org/mockolate.html)
- [Getting Mockolate](http://mockolate.org/getting_mockolate.html)
- [Preparing and Creating](http://mockolate.org/preparing_and_creating.html)
- [Stubbing and Mocking](http://mockolate.org/stubbing_and_mocking.html)
- [Recoding and Replaying](http://mockolate.org/recording_and_replaying.html)
- [Verifying and Test Spies](http://mockolate.org/verifying_and_test_spies.html)
- [Decorating Mockolates](http://mockolate.org/decorating_mockolates.html)
- [Limitations and Gotchas](http://mockolate.org/limitations_and_gotchas.html)

Thanks
------

[](#thanks)

Richard Szalay with [FLoxy](http://code.google.com/p/floxy/), and Maxim Porges with [Loom](http://code.google.com/p/loom-as3/) for their work on Class proxy generation.

Brian LeGros for hassling me about -mock-as3- enough that I added class proxy generation to it. Except you can ignore that project in favour of Mockolate.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.8% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/76caab2626cdfa35e2b169e284e6975c83b495f659cd1b21539d4b904f2af071?d=identicon)[jeroendelau](/maintainers/jeroendelau)

---

Top Contributors

[![drewbourne](https://avatars.githubusercontent.com/u/31808?v=4)](https://github.com/drewbourne "drewbourne (273 commits)")[![blegros](https://avatars.githubusercontent.com/u/148646?v=4)](https://github.com/blegros "blegros (5 commits)")[![fhd](https://avatars.githubusercontent.com/u/383120?v=4)](https://github.com/fhd "fhd (2 commits)")[![jeroendelau](https://avatars.githubusercontent.com/u/5286898?v=4)](https://github.com/jeroendelau "jeroendelau (2 commits)")

### Embed Badge

![Health badge](/badges/jeroendelau-mockolate/health.svg)

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

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)

PHPackages © 2026

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