PHPackages                             kenjis/phpunit-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. kenjis/phpunit-helper

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

kenjis/phpunit-helper
=====================

Provides helper traits for PHPUnit

v1.1.2(4y ago)513.0k↓30%3MITPHPPHP ^7.3||^8.0

Since Feb 1Pushed 4y ago1 watchersCompare

[ Source](https://github.com/kenjis/phpunit-helper)[ Packagist](https://packagist.org/packages/kenjis/phpunit-helper)[ Docs](https://github.com/kenjis/phpunit-helper)[ RSS](/packages/kenjis-phpunit-helper/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (3)

PHPUnit Helper
==============

[](#phpunit-helper)

Provides helper traits for PHPUnit.

- [TestDouble](#testdouble) ... Easy mock creation
- [ReflectionHelper](#reflectionhelper) ... Easy private property/method testing
- [DebugHelper](#debughelper) ... Helper function `dd()` and `d()`

Table of Contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
    - [`TestDouble`](#testdouble)
        - [`$this->getDouble()`](#this-getdouble)
        - [`$this->verifyInvoked()`](#this-verifyinvoked)
        - [`$this->verifyInvokedOnce()`](#this-verifyinvokedonce)
        - [`$this->verifyInvokedMultipleTimes()`](#this-verifyinvokedmultipletimes)
        - [`$this->verifyNeverInvoked()`](#this-verifyneverinvoked)
    - [`ReflectionHelper`](#reflectionhelper)
        - [`$this->getPrivateProperty()`](#this-getprivateproperty)
        - [`$this->setPrivateProperty()`](#this-setprivateproperty)
        - [`$this->getPrivateMethodInvoker()`](#this-getprivatemethodinvoker)
    - [`DebugHelper`](#debughelper)
- [License](#license)

Requirements
------------

[](#requirements)

- PHP 7.3 or later

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

[](#installation)

Run:

```
$ composer require --dev kenjis/phpunit-helper
```

Usage
-----

[](#usage)

### `TestDouble`

[](#testdouble)

This trait provides helper methods to create mock objects and to verify invocations.

Import the `Kenjis\PhpUnitHelper\TestDouble` trait into your test class:

```
