Listeners to speed up PHPUnit tests
Clone or download
Latest commit 91dae70 Jun 8, 2018
Failed to load latest commit information.
src Update TestListener Mar 13, 2018
tests add phpunit >=5.7 <7 compatibility Jun 21, 2017
.gitignore Initial commit Mar 13, 2014
.travis.yml Add PHP 7.2 Mar 13, 2018
LICENSE Update LICENSE Mar 16, 2017 Update May 20, 2015
composer.json Update composer.json Mar 13, 2018
phpunit.xml.dist Fix tests not running Dec 29, 2015

PHPUnit Accelerator

Build Status

Inspired by Kris Wallsmith faster PHPUnit article, we've created a PHPUnit test listener that speeds up PHPUnit tests about 20% by freeing memory.


To install this library, run the command below and you will get the latest version

composer require mybuilder/phpunit-accelerator --dev


Just add to your phpunit.xml configuration

        <listener class="\MyBuilder\PhpunitAccelerator\TestListener"/>

Ignoring Tests

Sometimes it is necessary to ignore specific tests, where freeing their properties is undesired. For this use case, you have the ability to extend the behaviour of the listener by implementing the IgnoreTestPolicy interface.

As an example, if we hypothetically wanted to ignore all tests which include "Legacy" in their test filename, we could create a custom ignore policy as follows


use MyBuilder\PhpunitAccelerator\IgnoreTestPolicy;

class IgnoreLegacyTestPolicy implements IgnoreTestPolicy {
    public function shouldIgnore(\ReflectionObject $testReflection) {
        return strpos($testReflection->getFilename(), 'Legacy') !== false;

And pass it to the constructor of our test listener in phpunit.xml configuration

        <listener class="\MyBuilder\PhpunitAccelerator\TestListener">
                <object class="\IgnoreLegacyTestPolicy"/>

Created by MyBuilder - Check out our blog for more insight into this and other open-source projects we release.