Elektrine lite

← Feed

@jclermont@phpc.social

2026-07-29 12:45 UTC

Ever been tempted to make a property public just so a test can assert on it? Today's tip shares a rule we follow on every project, and the trick that lets you keep your tests isolated without touching application code. #php #laravel https://masteringlaravel.io/daily/2026-07-29-republished-avoid-changing-your-code-purely-for-a-test

Replies (1)

  • @tvbeek@phpc.social 2026-07-29 14:02

    @jclermont@phpc.social My question always is: Why do you want a private/protected property? Is the internal that important or are you testing the incorrect thing? Not because it can't be useful but more because most of the time it isn't needed. So in fact my question is: do you need it more then once so a helper function is worth it?

    Open ##5194327