Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Traits Laravel Package

phpunitgoodpractices/traits

A small set of PHP traits to improve PHPUnit test code by reducing boilerplate and encouraging cleaner, reusable assertions and setup patterns. Useful for Laravel and general PHP projects that want more readable, maintainable tests.

View on GitHub
Deep Wiki
Context7

❗ THIS PACKAGE IS DEPRECATED ❗

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

ExpectationViaCodeOverAnnotationTrait

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

ExpectOverSetExceptionTrait

Expectation shall be set directly over via setter.

IdentityOverEqualityTrait

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

ProphecyOverMockObjectTrait

Prophecy shall be used over Mock Objects.

ProphesizeOnlyInterfaceTrait

Prophecy shall be created only for (existing) interfaces.

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

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport