Closed danielh-official closed 1 month ago
Would it be possible to implement preset overriding functionality?
So, you still have the preset, but if there's something in the latest Laravel release that doesn't match convention, rather than waiting for the package to be updated, a developer can write:
arch()->preset()->laravel()
->setExpectation('App\Http\Controllers')
->not->toHavePublicMethodsBesides(['__construct', '__invoke', 'index', 'show', 'create', 'store', 'edit', 'update', 'destroy', 'middleware']);
And it would override the previous expectation that tackles that part of the Controller architecture.
I mean is it more than 1 controller? An easy fix would just be to ignore it for now?
arch()->preset()->laravel()->ignoring(FeedController::class);
A better fix would be to fork the Pest repo & submit a PR to add the middleware method in the array, IMO given it's a framework convention, it should be added unless laravel removes this functionality.
What Happened
Laravel 11 allows you to specify middleware in a controller using a public static middleware function: https://laravel.com/docs/11.x/controllers#controller-middleware
However, the Laravel preset says that the only functions allowed to exist on a controller are the following:
How to Reproduce
ArchitectureTest.php
file in the Unit folderarch()->preset()->laravel();
to itDummyController.php
in theApp/Http/Controllers
folder and add the following code:Sample Repository
No response
Pest Version
3.0.1
PHP Version
8.2
Operation System
macOS
Notes
No response