This package is abandoned and no longer maintained. No replacement package was suggested.

Highly opinionated PHPUnit good practices enforcer.

v1.9.2 2022-08-29 18:04 UTC


With great shape of PHPUnit itself and Static Code Analysers supporting it, this package is no longer needed.

PHPUnit Good Practices

Highly opinionated PHPUnit good practices enforcer.

Available traits


Expected exception shall be set up via code, not annotations.


Expectation shall be set directly over via setter.


Identity assertion (===) shall be used over equality ones (==).


Prophecy shall be used over Mock Objects.


Prophecy shall be created only for (existing) interfaces.

Example usage


namespace FooProject\Tests;

use PHPUnit\Framework\TestCase;
use PHPUnitGoodPractices\Traits\ExpectationViaCodeOverAnnotationTrait;
use PHPUnitGoodPractices\Traits\ExpectOverSetExceptionTrait;
use PHPUnitGoodPractices\Traits\IdentityOverEqualityTrait;
use PHPUnitGoodPractices\Traits\ProphecyOverMockObjectTrait;
use PHPUnitGoodPractices\Traits\ProphesizeOnlyInterfaceTrait;

final class FooTest extends TestCase
    use ExpectationViaCodeOverAnnotationTrait;
    use ExpectOverSetExceptionTrait;
    use IdentityOverEqualityTrait;
    use ProphecyOverMockObjectTrait;
    use ProphesizeOnlyInterfaceTrait;

    public function testBar()
        $this->assertEquals(123, 213); // will report non-strict assertion usage