Skip to content

Instantly share code, notes, and snippets.

@james2doyle
Last active May 2, 2024 17:57
Show Gist options
  • Save james2doyle/a26f04cd0b6470cf7acb01575032bad8 to your computer and use it in GitHub Desktop.
Save james2doyle/a26f04cd0b6470cf7acb01575032bad8 to your computer and use it in GitHub Desktop.
Pest PHP architecture tests for new Laravel projects. https://twitter.com/AshAllenDesign/status/1786037324775633109
<?php
/** @see https://twitter.com/AshAllenDesign/status/1786037324775633109 */
test('strict types are used everywhere')
->expect('App')
->toUseStrictTypes();
test('globals')
->expect(['dd', 'ddd', 'die', 'dump', 'ray', 'sleep'])
->toBeUsedInNothing();
test('models extends base model')
->expect('App\Models')
->toExtend(Model::class);
test('controllers')
->expect('App\Http\Controllers')
->toBeClasses()
->classes()
->toExtend(Controller::class);
test('commands')
->expect('App\Console\Commands')
->toBeClasses()
->toExtend(Command::class)
->toHaveMethod('handle');
// add events and listeners?
test('jobs')
->expect('App\Jobs')
->toBeClasses()
->toImplement(ShouldQueue::class)
->toHaveMethod('handle');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment