anthonyedmonds/laravel-testing-traits

Make testing easier with this collection of testing traits!

0.5.0 2024-10-07 10:09 UTC

This package is auto-updated.

Last update: 2024-11-07 10:22:04 UTC


README

Make testing easier with this collection of testing traits!

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 [
        'user_model' => \App\Models\User::class,
    ];

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