anthonyedmonds/laravel-testing-traits

使用这个测试特性集合使测试更加容易!

0.2.0 2024-09-11 11:38 UTC

This package is auto-updated.

Last update: 2024-09-11 13:22:05 UTC


README

使用这个测试特性集合使测试更加容易!

安装

  1. 使用Composer添加库
    composer require anthonyedmonds\laravel-database-log --dev
  2. 服务提供者将被自动注册。如果需要,您可以手动注册服务提供者,将其添加到您的bootstrap/providers.php中
    return [
        ...
        AnthonyEdmonds\GovukLaravel\Providers\GovukServiceProvider::class,
        ...
    ];
  3. 如果您不使用标准的App\Models\User模型,请使用Artisan发布配置文件
    php artisan vendor:publish --provider="AnthonyEdmonds\LaravelTestingTraits\TestingTraitsServiceProvider"
    
    然后更新配置以指向您的模型
    return [
        'user_model' => \App\Models\User::class,
    ];

用法

  1. 将所需的特性添加到您的Tests\TestCase.php类中
  2. 在您的测试中使用测试方法
    $this->assertFormRequestPasses(...);
    $this->assertBelongsTo(...);

可用的特性