Skip to content

Latest commit

 

History

History
81 lines (71 loc) · 2.02 KB

arch-testing.md

File metadata and controls

81 lines (71 loc) · 2.02 KB
test('the codebase does not contain any debugging code')
    ->expect(['dd', 'dump', 'ray', 'var_dump', 'print_r'])
    ->not->toBeUsed();
test('the codebase does not reference env variables outside of config files')
    ->expect('env')
    ->not->toBeUsed();
test('Application files use strict types')
    ->expect('App')
    ->toUseStrictTypes();
test('Mailables are extending the correct class')
    ->expect('App\Mail')
    ->toBeClasses()
    ->classes->toBeFinal() // optional
    ->classes->toExtend('Illuminate\Mail\Mailable')
    ->classes->toImplement('Illuminate\Contracts\Queue\ShouldQueue'); // optional
test('Models are extending the correct class')
    ->expect('App\Models')
    ->toBeClasses()
    ->classes->toBeFinal() // optional
    ->classes->toExtend('Illuminate\Database\Eloquent\Model');
test('Providers are extending the correct class')
    ->expect('App\Providers')
    ->toBeClasses()
    ->classes->toBeFinal() // optional
    ->classes->toExtend('Illuminate\Support\ServiceProvider')
    ->classes->toImplementNothing();
test('Requests are extending the correct class')
    ->expect('App\Http\Requests')
    ->toBeClasses()
    ->classes->toBeFinal() // optional
    ->classes->toExtend('Illuminate\Foundation\Http\FormRequest');
test('API Controllers are not extending anything')
    ->expect('App\Http\Controllers\Api')
    ->toBeClasses()
    ->classes->toBeFinal() // optional
    ->classes->toExtendNothing();
test('Commands are extending the correct class')
    ->expect('App\Console\Commands')
    ->toBeClasses()
    ->classes->toBeFinal() // optional
    ->classes->toExtend('Illuminate\Console\Command');
test('Tests are using strict types and have the correct suffix')
    ->expect('Tests')
    ->toUseStrictTypes()
    ->and('Tests\Feature')->toHaveSuffix('Test')
    ->and('Tests\Unit')->toHaveSuffix('Test');
test('Actions are invokable')
    ->expect('App\Actions')
    ->toBeInvokable();