pest
pest copied to clipboard
[Feature] Architecture toUseTrait()
We try to write tests to ensure our internal coding guidelines are followed. For example, we would like to ensure that a given trait is not used in some namespaces:
test('Ensure actions do not implement the AsAction trait')
->expect('App\Actions')
->classes()
->not
->totUseTrait(\Lorisleiva\Actions\Concerns\AsAction::class);
Would this be nice? Please share your thoughts, so we may create a pull request with our implementation.
I'm trying to implement something similar at the moment, checking uuid's are used on models, so looking for HasUuids trait
Why not just use toUse()
?
@EPGDigital-MW you can also just use toUse()
for that
I'm sure I tried toUse and it didn't work, but I've just tried again and it's working no idea why it didn't work first time ;)
I think toUseTrait would be useful still as provides clarity on what you are testing.
I'm pretty sure there's a PR to add that as an Expectation but it was closed and the solution was to just use toUse()
. You can try again but no promises it'll be accepted.
Yes, the pull request was closed: https://github.com/pestphp/pest/pull/960 So I will use toUse():
test('Ensure actions do not implement the all in one AsAction trait.')
->expect('App\Actions')
->not
->toUse(\Lorisleiva\Actions\Concerns\AsAction::class);