PHPackages                             unit-testing/mockery-helper - 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. unit-testing/mockery-helper

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

unit-testing/mockery-helper
===========================

a simple trait for convenient implementation of mockery mocks and spies in PHPUnit tests

v1.0.0(11y ago)068MITPHPPHP &gt;=5.4.0

Since Feb 27Pushed 11y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (2)Used By (0)

UnitTesting\\MockeryHelper
==========================

[](#unittestingmockeryhelper)

Simple module to help with creating mocks using mockery. You won't have to continually reference `Mockery\Mockery` and keep your tests a little DRY'er.

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

[](#installation)

- `composer require --dev unit-testing/mockery-helper:dev-master`
- or in `require-dev` block of `composer.json`, add `"unit-testing/mockery-helper": "dev-master"` and then run `composer update`
- don't forget to `require-dev` `mockery/mockery`

Usage
-----

[](#usage)

- In your phpunit test, `use UnitTesting\MockeryHelper\MockeryTrait`.
- in your `tearDown()` method call `$this->closeMocks()`
- When you want to mock something, use `$this->mock()` as an alias for `Mockery::mock()`
- You can also use `$this->spy()` as an alias for `Mockery::spy()`
- Use the result of one of the above function calls as you normally would for your assertions.
- `mockery` method simply forwards any call to the Mockery static. The first argument is the method, and subsequent arguments are params for the Mockery method.

Example
-------

[](#example)

```
