{"slug": "i-write-my-php-testing-framework-with-ai-here-s-how-the-quality-stays-high", "title": "I write my PHP testing framework with AI. Here's how the quality stays high.", "summary": "A developer released MicroUnit 1.0, a zero-dependency PHP testing framework whose code, tests and documentation were largely AI-generated, with quality enforced through a review-and-verification pipeline. Every change runs a twelve-way CI matrix (Ubuntu, Windows and macOS across PHP 8.5 and 8.6, sequential and four-worker parallel), a self-hosted suite, a canary script that checks failure reporting with plain PHP, and a check that flags tests weakened by deleted assertions or altered expected values. The developer said AI expanded capacity rather than lowering standards, and the matrix caught three platform-specific bugs before release, including a Windows PHP 8.5 parallel worker that lost results.", "body_md": "MicroUnit 1.0 came out this week. It's a PHP testing framework with zero dependencies, and almost all of its code, tests and documentation started as AI output. I chose that on purpose, and I'm saying it up front because I know how that sentence lands in 2026. \"Written with AI\" reads to a lot of developers like \"nobody really checked\".\n\nSo this post is about the checking. Not \"trust me\", but the actual setup, with links, so you can decide for yourself.\n\nMicroUnit started in May 2025 as a side project. By the summer it had a public beta, and then it stalled. Code coverage, parallel runs, a browser UI, framework integrations: building all of that next to a full-time job was too much for one person. Testing it properly was even more.\n\nAI changed the capacity, not the standard. With it, I could test each feature from several sides, how it fails as well as how it passes, which I would never have had the time for on my own.\n\nThe split is simple. I decide what MicroUnit does and what it leaves out, how every public API reads in a test, and the architecture. AI implements those decisions, writes the tests for them and writes the docs from the source. Then I review every change.\n\nMy review is the one step nobody can verify from the outside. It covers what no automated check can: whether a change is the right one, whether an API reads well, whether a test checks the right thing in the first place. Everything that can be checked automatically is, on every change, so my attention goes where only a person helps.\n\nEvery AI session starts with the same rules. `CLAUDE.md` in the repo holds the code rules (zero dependencies, typed, `final readonly` by default, no dead code), the commands, the known pitfalls and what \"done\" means: tests added, suite, canary, lint and PHPStan green, docs updated in the same change.\n\nMicroUnit also answers the agent in a format built for it: one compact JSON object with only the failures, each with the file and line, expected and actual values, plus a warning for every test that passes without asserting anything. The agent's attention goes to what broke, not to a wall of green dots.\n\nEvery push and pull request runs the full suite twelve times: Ubuntu, Windows and macOS, PHP 8.5 and 8.6, once sequentially and once spread over four parallel workers. `error_reporting=-1` and OPcache off, so every notice counts and every run compiles from scratch.\n\nThe sequential/parallel pair catches a nasty class of bug: tests that quietly depend on what another test left behind. And the matrix earns its keep. Just before the release, it surfaced three real bugs that only appeared on some platforms, including a parallel worker on Windows with PHP 8.5 whose results got lost. Each fix shipped with a test.\n\nThe suite runs on MicroUnit itself. That's a loop: a change goes in, its own suite runs with the code that just changed, a test turns red, the fix comes with a test that stays forever.\n\nThe obvious question: could a broken MicroUnit pass its own tests? It's harder than it sounds, because dozens of tests check that assertions *fail* when they should, and those are checked by different code (`Assert::throws()` checking `Assert::exact()`, for example). Integration tests run the real command line as a separate process against projects with known outcomes.\n\nThe one thing a loop can't judge about itself is whether failures get reported at all. That's what the canary is for: a tiny script that loads none of MicroUnit's code, runs four tests with known outcomes (one passes, three fail in different ways) and checks the exit code and the report with plain PHP. If MicroUnit ever stops telling red from green, the canary goes red first.\n\nWhen a test goes red, an agent can make it green the wrong way: delete the assertion, change the expected value to whatever the code returns now, add a skip. That's the specific risk that comes with AI, so MicroUnit has a check for exactly that. It compares the tests with the previous version and lists removed assertions, changed expected values, new skips and removed tests.\n\nIn an agent session it runs after every test run, so the agent hears about it while it's still working. On pull requests, any finding fails the build. And it isn't special tooling for my repo: any project can turn it on with `withIntegrityCheck()`.\n\n`src/` and `bin/`, no baseline file. It runs as a PHAR, so it doesn't break the zero-dependency rule.\nMy own suite only contains the cases I thought of. So before a release, MicroUnit runs the test suites of six real open-source projects: brick/math, nesbot/carbon, webmozart/assert, league/commonmark, symfony/yaml and monolog/monolog. Their tests are translated with `microunit migrate`, nobody touches the result by hand, and a project only counts when every test passes and MicroUnit runs exactly as many tests as PHPUnit does. The same runs feed the benchmarks, and everything is reproducible.\n\nI don't think AI makes software trustworthy or untrustworthy on its own. What makes it trustworthy is what surrounds it, and whether you can see that. Everything above is public: the pipeline, the canary, the lint, the PHPStan config, the integrity check.\n\nIf you find a hole in this setup, I'd genuinely like to hear it.", "url": "https://wpnews.pro/news/i-write-my-php-testing-framework-with-ai-here-s-how-the-quality-stays-high", "canonical_source": "https://dev.to/micro_unit_php/i-write-my-php-testing-framework-with-ai-heres-how-the-quality-stays-high-4d25", "published_at": "2026-11-23 10:10:11+00:00", "updated_at": "2026-11-23 10:12:08.193049+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents"], "entities": ["MicroUnit", "PHP", "PHPStan", "Claude"], "also_reported_by": [], "takeaway": "Pair AI-written tests with a canary script that loads none of the framework's code and checks exit codes and reports with plain PHP, plus a diff check that flags removed assertions or altered expected values, so an agent can't make a red test green by weakening it.", "recommendation": {"advice": "Run every change through a sequential/parallel CI matrix and a plain-PHP canary that verifies failure reporting, and diff tests against the previous version to catch deleted assertions or changed expected values.", "playbook": "evals-testing", "playbook_url": "https://wpnews.pro/playbooks/evals-testing"}, "alternates": {"html": "https://wpnews.pro/news/i-write-my-php-testing-framework-with-ai-here-s-how-the-quality-stays-high", "markdown": "https://wpnews.pro/news/i-write-my-php-testing-framework-with-ai-here-s-how-the-quality-stays-high.md", "text": "https://wpnews.pro/news/i-write-my-php-testing-framework-with-ai-here-s-how-the-quality-stays-high.txt", "jsonld": "https://wpnews.pro/news/i-write-my-php-testing-framework-with-ai-here-s-how-the-quality-stays-high.jsonld"}}