Does it *need* to be a DTO? #25
Replies: 4 comments 4 replies
-
Good question! Theoretically, we could use the same approach we are with DTOs on other classes. I think the main reason we targeted DTOs specifically was because there was a need for them to be mocked on occasion and they are easy to support. By opening ourselves up to other classes there are a lot of variables that need to be accounted for (e.g. if the class passed has a constructor dependency, how do we handle that?). I am not opposed to pursuing that if the interest is there. We would need to give a little thought into what that looks like though. Is this something you would find useful? |
Beta Was this translation helpful? Give feedback.
-
Ah true, I've been doing symfony/serializer stuff lately and the amount of different cases they have to handle is scary! This is sort of what I was looking for but is quite outdated now - https://github.com/stephanecoinon/object-factory |
Beta Was this translation helpful? Give feedback.
-
There is certainly potential for a Laravel-like factory package to assist in mocking objects in general (not just models). I would have to think about whether that would be useful to most people, since usually factories are pretty customized to what they are generating. If we were to implement that, it would be in a different package though. Our main interest here is creating populated DTOs so we can test actions on them instead of spending time generating the correct types for each property. 🙂 |
Beta Was this translation helpful? Give feedback.
-
@aidan-casey I forked a lot of the code from this package to adapt it for POPOs. https://github.com/morrislaptop/popo-factory It would be great to see if it could work together somehow? |
Beta Was this translation helpful? Give feedback.
-
Could this library just work by examining the public properties of a class using reflection?
Beta Was this translation helpful? Give feedback.
All reactions