Skip to content
Programing

PHPUnit 13.1 and the 2026 Roadmap: Transitioning to PHP 8.4+ Testing Standards

Published: Duration: 5:45
0:00 0:00

Transcript

Host: Alex Chan Guest: Marcus Thorne (Senior Architect and PHP Core contributor focus) Host: Hey everyone, welcome back to Allur! I’m your host, Alex Chan, and today we are talking about something that is probably sitting in your vendor folder right now, but maybe hasn't gotten the love it deserves lately: your testing suite. We’ve all been there—you’re trying to push a feature, the CI pipeline fails because of some "magic" mock that decided to break for no reason, and you spend three hours fighting the framework instead of writing code. Host: I am so excited to be joined by Marcus Thorne. Marcus is a Senior Architect who has spent years helping enterprise teams migrate massive legacy codebases into the modern era. He’s also a frequent contributor to the discussions around PHP standards. Marcus, welcome to Allur! Guest: Thanks so much for having me, Alex. It’s a great time to be talking about this—testing is finally getting as "grown-up" as the PHP engine itself. Host: It really is! I mean, I remember when PHPUnit felt like this separate thing you just tacked on. But with 13.1, it feels like it’s becoming inseparable from the PHP engine. What’s the "big why" behind this aggressive move toward PHP 8.4 standards? Guest: Honestly, Alex, it’s about performance and stability. For years, PHPUnit had to do these… um, let’s call them "acrobatics" to work around limitations in the PHP engine. If you wanted to mock something or inspect a class, the framework had to use high-overhead workarounds. By targeting PHP 8.4, PHPUnit can now use things like property hooks and better type variance directly at the engine level. It makes the tests faster, but more importantly, it makes them more predictable. No more "black box" magic. Host: Interesting! So, you’re saying by being stricter, it actually becomes easier to maintain? Because usually, "stricter" sounds like "more work" for the developer. Guest: (Laughs) It is a bit more work upfront, definitely. But think about the "magic" mocks we used to use. You know, using `getMockBuilder()` and disabling constructors, and then mocking a private method just to get a test to pass? Host: Oh, I am definitely guilty of that. Sometimes you just want to get the green light! Guest: We all are! But that’s the "brittle test" trap. PHPUnit 13.1 is starting to dismantle those legacy behaviors. If you try to mock a method that doesn't exist, or a private method, the framework is basically going to say, "No, fix your design." It’s pushing us toward better encapsulation. If you *have* to mock a private method, it’s usually a code smell that your class is doing too much anyway. Host: That’s a tough pill to swallow for some legacy projects. I saw the example in the release notes about moving away from `getMockBuilder()` toward `createMock()`. Why is that shift so central to the 13.1 philosophy? Guest: It’s about being explicit. `getMockBuilder()` is very "stringy" and loose. `createMock(Service::class)` is type-safe. When you use the modern, explicit patterns, the framework can actually validate that the contract of the interface is being respected. It stops you from writing a test that passes against a—well, a "hallucinated" API that doesn't actually exist in your production code. Host: A hallucinated API—I love that. It’s like the test is lying to you! Now, let’s talk about this 2026 roadmap. That sounds like a long way off, but the 13.2 release in June 2026 is being framed as this major milestone. Why such a long runway? Guest: It’s actually a really smart move by Sebastian and the maintainers. They’re giving us a "grace period." Version 13.1 is where the warnings start appearing. If you run your tests today with `--display-deprecations`, you’ll see exactly what’s going to break in 13.2. That June 2026 date is the deadline for the "cleanup." By then, all that legacy stuff—the dynamic properties, the loose mocks—it’s all going away. They’re giving us two years to do "continuous refactoring" instead of a "big bang" upgrade that breaks everything on a Friday afternoon. Host: Right, because no one wants to spend a whole week just fixing test headers. So, if I’m a lead dev listening to this, and I’ve got a massive test suite, what’s my first step? Do I just update `composer.json` and hope for the best? Guest: (Chuckles) Definitely don't just "hope for the best." First step: Audit. Run your suite with the deprecation flags on. See how loud it is. Then, I highly recommend bringing in static analysis tools like PHPStan or Psalm if you aren’t using them yet. They work hand-in-hand with PHPUnit 13.1. They’ll catch those "brittle" tests where you’re asserting types on dynamic properties before you even run the code. Host: That makes sense. It’s like having a second pair of eyes. I also noticed the mention of "anonymous classes" for complex stubs. Is that the new standard when `createMock` isn't enough? Guest: Exactly. Instead of using a heavy mocking engine to "fake" a complex behavior, just write a small anonymous class that implements the interface. It’s pure PHP. It’s fast, it’s type-safe, and it won't break when PHPUnit updates its internals. It’s about getting back to basics. Host: It’s almost like the industry is circling back to "simpler is better," but with much stronger guardrails. Guest: Exactly. We’re moving away from "clever" and toward "reliable." Host: I love that. "Reliable over clever" should be the motto for 2026. Marcus, before we wrap up, what’s one piece of advice you’d give to someone who feels overwhelmed by these changes? Guest: Don’t try to fix it all in one sprint. Use the roadmap. Every time you touch a feature, fix the tests in that domain. If you do a little bit of "continuous refactoring" every week, by June 2026, you’ll just be sliding into 13.2 and PHPUnit 14 with zero stress. Host: That is such a great takeaway. Continuous refactoring over the "big bang" failure. Marcus, thank you so much for joining us and breaking this down. It makes the future of PHP testing feel a lot less intimidating. Guest: My pleasure, Alex. Thanks for having me! Host: For everyone listening, if you want to see the code examples Marcus mentioned, check out the show notes for links to the PHPUnit 13.1 release notes and the 2026 roadmap details. Start running those deprecation checks now—your future self will thank you!

Tags

open-source php testing performance modernization phpunit