PHPackages                             anthonyedmonds/laravel-testing-traits - 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. anthonyedmonds/laravel-testing-traits

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

anthonyedmonds/laravel-testing-traits
=====================================

Make testing easier with this collection of testing traits!

1.3.0(1mo ago)05.1k↓50%5MITPHPPHP ^8.3

Since Sep 11Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/AnthonyEdmonds/laravel-testing-traits)[ Packagist](https://packagist.org/packages/anthonyedmonds/laravel-testing-traits)[ Docs](https://github.com/AnthonyEdmonds/laravel-testing-traits)[ RSS](/packages/anthonyedmonds-laravel-testing-traits/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (29)Used By (5)

Laravel Testing Traits
======================

[](#laravel-testing-traits)

Make testing easier with this collection of testing traits!

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

[](#installation)

1. Add the library using Composer: ```
    composer require anthonyedmonds/laravel-testing-traits --dev
    ```
2. The service provider will be automatically registered. If required, you can manually register the service provider by adding it to your bootstrap/providers.php: ```
    return [
        ...
        AnthonyEdmonds\GovukLaravel\Providers\GovukServiceProvider::class,
        ...
    ];
    ```
3. If you are not using the standard `App\Models\User` model, publish the config file using Artisan: ```
    php artisan vendor:publish --provider="AnthonyEdmonds\LaravelTestingTraits\TestingTraitsServiceProvider"

    ```

    Then update the config to point to your model: ```
    return [
        'exclude_views' => [
            '::',
            'errors.',
            'vendor.',
        ],
        'user_model' => \App\Models\User::class,
    ];
    ```

Usage
-----

[](#usage)

1. Add the desired traits to your `Tests\TestCase.php` class
2. Use the test methods in your tests: ```
    $this->assertFormRequestPasses(...);
    $this->assertBelongsTo(...);
    ```

Available traits
----------------

[](#available-traits)

TraitPurposeMethodsAssertsActivitiesTest whether a Spatie/ActivityLog has been recordedassertActivityAssetsFlashMessagesTest whether a Laracasts/Flash message has been setassertFlashedAssertsFormRequestsTest whether a FormRequest validates as expectedassertFormRequestPasses, assertFormRequestFailsAssertsOrderTest whether a Collection is in orderassertAscending, assertDescendingAssertsPoliciesTest whether a Policy works as expectedassertPolicyAllows, assertPolicyDeniesAssertsRelationshipsTest whether a Model relationship loads as expectedassertBelongsTo, assertBelongsToMany, assertHasMany, assertHasOneAssertsResultsTest whether a Collection contains the expected valuesassertResultsMatch, assertResultsContain, assertResultsDontContain, assertResultsCountAssertsValidationRulesTest whether a custom Rule works as expectedassertRulesPasses, assertRuleFailsAssertsViewsTest whether a View renders as expectedassertViewRenders, assertMailRenders, assertNotificationRendersFakesRoutesFool Laravel into thinking you are on a specific routefakeRouteGetsRawCsvsProcess a raw CSV into an array for parsingprocessRawCsvGetsStreamedResponsesIntercept a StreamedResponse for testing filesgetStreamedResponseSetsViewVariablesSet View variables for testing rendered blades, such as with MojitosetRequestOld, setViewAttributes, setViewErrors, setViewSlotSignsInUsersSign a User in with relevant Spatie/LaravelPermission Roles and PermissionssignIn, signInAs, signInWithRole, signInWithPermissionPHPUnit Extension
-----------------

[](#phpunit-extension)

An extension is provided for asserting that all blade files in your project have been rendered successfully.

When used in conjunction with `assertViewRenders`, an check will be performed at the end of all unit tests to ensure that all blade files within `resources/views` have been rendered at least once.

```

```

The results are output into the terminal and recorded in `.phpunit.cache/view-render-results.json`.

You can configure which views are excluded from the count by adding wildcards to the `exclude_views` key of the `testing-traits` config file.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance89

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 86.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~21 days

Recently: every ~52 days

Total

27

Last Release

56d ago

Major Versions

0.7.7 → 1.0.02025-04-10

PHP version history (3 changes)0.0.0PHP ^8.3

0.0.1PHP ^8.2

1.0.0PHP ^8

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17785811?v=4)[Anthony Edmonds](/maintainers/AnthonyEdmonds)[@AnthonyEdmonds](https://github.com/AnthonyEdmonds)

---

Top Contributors

[![AnthonyEdmonds](https://avatars.githubusercontent.com/u/17785811?v=4)](https://github.com/AnthonyEdmonds "AnthonyEdmonds (26 commits)")[![calum-gray](https://avatars.githubusercontent.com/u/182486957?v=4)](https://github.com/calum-gray "calum-gray (3 commits)")[![TUddin01](https://avatars.githubusercontent.com/u/73365097?v=4)](https://github.com/TUddin01 "TUddin01 (1 commits)")

---

Tags

testingphpunitlaraveltraits

### Embed Badge

![Health badge](/badges/anthonyedmonds-laravel-testing-traits/health.svg)

```
[![Health](https://phpackages.com/badges/anthonyedmonds-laravel-testing-traits/health.svg)](https://phpackages.com/packages/anthonyedmonds-laravel-testing-traits)
```

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[guanguans/laravel-soar

SQL optimizer and rewriter for laravel. - laravel 的 SQL 优化器和重写器。

2227.8k](/packages/guanguans-laravel-soar)[sofa/laravel-kahlan

Kahlan specs suite for testing Laravel applications

1524.2k](/packages/sofa-laravel-kahlan)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
