Enterprise AI architect & engineer. Available for AI workshops, advisory and production AI builds.

Social Links

Open Source Contributions

When Green Tests Aren’t Enough

Learn a key lesson from contributing to Laravel's core: even small changes with passing tests can introduce subtle issues. A must-read for Laravel contributors.

When Green Tests Aren’t Enough

A few days ago, I made a seemingly small change in the Laravel framework. I submitted a PR, and everything looked great — all tests passed, the logic was sound, and the code got merged.

Fast forward about four days later, someone left a comment on that PR pointing out a potential issue. Curious, I went back to review the change, and that’s when it hit me:

Even the simplest change in a project of this scale needs to be considered from multiple angles.

What I did was replace a small piece of duplicate logic with Laravel’s value() helper to improve readability and avoid redundancy. Everything was technically correct — the tests passed, the code worked. But what I missed was this: value() is defined in the illuminate/collections package, and the component I was modifying (illuminate/conditionable) is designed to be used standalone — it doesn’t depend on illuminate/collections.

So despite everything working fine in the context of Laravel, that small change introduced an implicit dependency, which could break things for anyone using Conditionable outside the framework.

🔍 The Takeaway:

This experience reminded me of something important:
Green tests don’t always mean your code is safe. Especially in mature, modular ecosystems like Laravel, it’s not just about whether your code works — it’s about where it lives, what it relies on, and who else might be using it in unexpected ways.

I’ve since opened a PR to revert that change, and I’m honestly glad this came up — it was a small mistake, but a valuable lesson.

2 min read
Apr 23, 2025
By Mohammadrasoul Asghari
Share

Leave a comment

Your email address will not be published. Required fields are marked *