Repository navigation
DisallowHasFactorySniff Why? #38
|
The package is very good, thank you very much I would like to understand why this rule exists: DisallowHasFactorySniff
|
Answered by
olivernybroe
Nov 30, 2022
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
|
1 reply
Answer selected by
sojeda
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@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