Skip to content

Instantly share code, notes, and snippets.

@michabbb
Last active May 16, 2024 13:07
Show Gist options
  • Save michabbb/279af3eea6029e7621e68edbc87cc89a to your computer and use it in GitHub Desktop.
Save michabbb/279af3eea6029e7621e68edbc87cc89a to your computer and use it in GitHub Desktop.
PestPHP architecture testing
<?php
/** @see https://www.linkedin.com/posts/ashleyjcallen_these-are-some-not-all-of-the-first-pest-activity-7191803157692190720-HAPK **/
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');
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