Forcing a class to be unit-testable #5970
olleharstedt
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A class can be unit-tested if:
Could it be interesting to add an option to Psalm to force a class or folder of a project to be unit-testable?
Example:
This would require that all built-in functions to PHP are marked as either pure or effectful. Don't know if this effort has been done already? Alternatively, it can assume that everything is effectful by default, unless tagged as pure.
Use-case of this functionality is to be able to force a divide in your code-base between blackbox and whitebox testing. Controller classes, for example, are often easier to blackbox test, while service classes with business logic could be whitebox tested. (Slightly related to "functional core, imperative shell" architectural pattern.)
Beta Was this translation helpful? Give feedback.
All reactions