PHPUnit: Guides and Practical Know-how | mironsoft Blog
PHPUnit
-
May 4, 2026
PHPUnit 10 replaced the long-grown TestListener with a cleanly typed Extension API. Anyone who wants custom logging, Slack notifications on failure, or project-specific rules inside their test suite will find the migration path here, with runnable examples.
-
Apr 21, 2026
An isolated observer test calls the observer class directly and never checks whether the event is actually wired correctly in events.xml. An end-to-end test through the real event dispatch closes exactly this gap.
-
Apr 12, 2026
A full reindex run is far too slow and too coarse for a test. Extracting the actual indexer logic into a separate class and calling it directly with prepared input data turns testing into a matter of milliseconds instead of minutes.
-
Apr 11, 2026
Magento's REST API is built on service contracts declared in webapi.xml, yet nothing in day-to-day work prevents an implementation from silently drifting away from the declared interface over time. Automated contract compliance tests close exactly that gap.
-
Apr 4, 2026
A failing parameterized test that only reports 'Data set #7' forces you to open the data provider and count entries by hand. With named arrays instead of numeric indexes, PHPUnit instead shows immediately which business case failed. This article walks through a real before and after example of adopting named datasets and the pitfalls along the way.
-
Mar 29, 2026
Anyone lifting a grown PHP project onto PHPUnit 10 or 11 runs into a flood of deprecation notices, changed assertion signatures, and removed interfaces. This article shows a structured path through the migration, without endangering the running test suite and without having to touch every test class at once.
-
Mar 29, 2026
A test that sometimes passes and sometimes fails is worse than no test at all. It erodes trust in the entire test suite, forces manual re-runs and hides real regressions behind noise. Flaky tests arise from specific root causes, and every single one of them can be fixed for good.
-
Mar 21, 2026
Anyone building Magento modules without integration tests only notices regressions in staging or in production. The Magento Test Framework provides a complete environment with real database isolation, automatic fixture management and the full Magento DI container, provided it is set up correctly.
-
Mar 17, 2026
Magento 2 exposes complex business logic through REST and GraphQL APIs. Anyone implementing custom endpoints, schema extensions, or API policies needs reliable integration tests, not manual Postman clicking, not "works on staging, fingers crossed".
-
Mar 8, 2026
Most PHP projects either have too many unit tests for code that depends on database state, or too few tests at the right level. The test pyramid is not an academic concept, it is a practical tool for deciding which test type solves which problem most efficiently.