Source: matthiasnoback.nl

Don't test constructors
Posted on May31st2021 by Matthias Noback@ediar asked me on Twitter if I still think a constructor should not be tested. It depends on the type of object you're working with, so I think it'll be useful to elaborate here. Would you test the constructor of a service that just gets some dependencies injected?

Yes, but in very specific ways, none of which is this one: ("Why do we need to know the user's gender?"

So then you want to write this test: At this point, the test "forces" you to keep track of the is-suspended state somehow, and of course, you'd do that with an object property.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners