PHPackages                             prodikl/mocktation - 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. prodikl/mocktation

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

prodikl/mocktation
==================

PHP Mocking using annotations

v1.0.3(8y ago)111[1 issues](https://github.com/prodikl/mocktation/issues)MITPHP

Since Mar 11Pushed 7y ago2 watchersCompare

[ Source](https://github.com/prodikl/mocktation)[ Packagist](https://packagist.org/packages/prodikl/mocktation)[ RSS](/packages/prodikl-mocktation/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (6)Used By (0)

Mocktation
==========

[](#mocktation)

PHP Mocking using annotations

[![Build Status](https://camo.githubusercontent.com/64a8aeb3608b8e58c69df29cdb7f01daf1b055def9b0c67919fb49dd48641ee1/68747470733a2f2f7472617669732d63692e6f72672f70726f64696b6c2f6d6f636b746174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/prodikl/mocktation)

Mocktation lets you define return values of class methods when mocking, instead of having to define each return value in your tests.

By annotating using `@mockReturn   "test"`, the method will return `"test"`by default when calling the method after creating a mock using `$this->createMock(CLASSNAME)` in your tests.

This speeds up development since you can define default mock return values when writing the method, instead of retroactively deciding on mock values.

1. Install Mocktation

    ```
    composer require-dev prodikl/mocktation
    ```
2. Extend `Mocktation/Testcase` instead of PHPUnit TestCases

    ```
    use Mocktation\TestCase;

    class ExampleTest extends TestCase {
        public function testGetNum(){
            /** @var Example|MockObject $mock */
            $mock = $this->createMock(Example::class);
            $this->assertEquals(5, $mock->getNum(234));
        }
    }
    ```
3. Use annotations to describe mocking in your methods

    ```
    class Example {
        /**
         * Accepts an int $num and returns it
         *
         * @param $num      int     The num to return
         * @return int      The example num
         *
         * @mockReturn      5
         */
        public function getNum($num){
            return $num;
        }
    }
    ```

Here's a list of Mocktation annotations

- `@mockReturn [returnValue]` - Returns the \[returnValue\] when called
- `@mockReturnArgument [argumentNumber]` - Returns the \[argumentNumber\] when called. \[argumentNumber\] starts from 0.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 81.3% 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 ~0 days

Total

4

Last Release

3033d ago

### Community

Maintainers

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

---

Top Contributors

[![prodikl](https://avatars.githubusercontent.com/u/4628774?v=4)](https://github.com/prodikl "prodikl (13 commits)")[![keithlarsonft](https://avatars.githubusercontent.com/u/60156519?v=4)](https://github.com/keithlarsonft "keithlarsonft (3 commits)")

---

Tags

annotationsmockingphpphp-mockingphpunitunit-testing

### Embed Badge

![Health badge](/badges/prodikl-mocktation/health.svg)

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

###  Alternatives

[brianium/paratest

Parallel testing for PHP

2.5k129.9M916](/packages/brianium-paratest)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k41.3M39.0k](/packages/orchestra-testbench)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.0M322](/packages/drupal-core-dev)[webmozarts/strict-phpunit

Enables type-safe comparisons of objects in PHPUnit

30300.1k6](/packages/webmozarts-strict-phpunit)

PHPackages © 2026

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