DisallowHasFactorySniff Why? #38
-
The package is very good, thank you very much I would like to understand why this rule exists: DisallowHasFactorySniff
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@sojeda Sure, will gladly explain why 🙂 The reason is that factories should be used in tests. Adding HasFactory to your model is adding code which is meant for testing into your application code. Essentially you end up having code which will never get called outside of tests in every single model. However it can be a bit annoying having to use the longer syntax in tests. 👀 I see three possible solutions here
|
Beta Was this translation helpful? Give feedback.
@sojeda Sure, will gladly explain why 🙂
The reason is that factories should be used in tests. Adding HasFactory to your model is adding code which is meant for testing into your application code.
Essentially you end up having code which will never get called outside of tests in every single model.
However it can be a bit annoying having to use the longer syntax in tests. 👀
I see three possible solutions here