2017-25 © Pedro Pelåez
 

library traits

Highly opinionated PHPUnit good practices enforcer.

image

phpunitgoodpractices/traits

Highly opinionated PHPUnit good practices enforcer.

  • Thursday, June 21, 2018
  • by keradus
  • Repository
  • 2 Watchers
  • 12 Stars
  • 9,798 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 19 Versions
  • 46 % Grown

The README.md

❗ THIS PACKAGE IS DEPRECATED ❗

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

PHPUnit Good Practices

Highly opinionated PHPUnit good practices enforcer., (*2)

Available traits

ExpectationViaCodeOverAnnotationTrait

Expected exception shall be set up via code, not annotations., (*3)

ExpectOverSetExceptionTrait

Expectation shall be set directly over via setter., (*4)

IdentityOverEqualityTrait

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

ProphecyOverMockObjectTrait

Prophecy shall be used over Mock Objects., (*6)

ProphesizeOnlyInterfaceTrait

Prophecy shall be created only for (existing) interfaces., (*7)

Example usage

<?php

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
    }
}

The Versions

22/02 2018

dev-shall_prophesize_only_interfaces

dev-shall_prophesize_only_interfaces

Highly opinionated PHPUnit good practices enforcer.

  Sources   Download

MIT

The Requires