PHPUnit: Guides and Practical Know-how | Page 3 | mironsoft Blog
PHPUnit
-
Dec 31, 2025
PHPUnit runs four different lifecycle hooks in a fixed order, two of them once per class, two of them before and after every individual test. Anyone unclear on this precise order easily ends up building tests that appear isolated but actually share state through static properties. This article walks through the full chain, the typical mistakes, and when static instead of instance methods are actually needed.
-
Dec 23, 2025
Parallel PHPUnit runs save time, but they place demands on database isolation, fixture design and configuration that many teams only discover after the first painful race condition. This article shows how to set up paratest correctly, why shared state is the most common source of errors, and how to make test suites genuinely parallel-safe.
-
Dec 16, 2025
Without clean fixtures, integration tests are fragile: tests create test data that affects the next test, rollbacks fail and the fixture script sits at a different path than expected. The Magento Test Framework offers a sophisticated fixture system, provided you understand the mechanisms behind it.
-
Dec 16, 2025
Untested GraphQL resolvers are a ticking time bomb: schema changes silently break frontend contracts, and authentication bugs stay hidden until production. This article shows how to test Magento GraphQL on three levels, from unit tests for resolver logic to real HTTP requests against the endpoint.
-
Dec 15, 2025
A chain of multiple assertEquals calls comparing individual fields of a domain object is tedious to write and only delivers fragmentary information on failure. Custom, domain specific assertions such as assertMoneyEquals or assertValidOrderState bundle these comparisons in one place and produce failure messages that immediately show what went wrong from a business perspective. This article explains how such assertions come together and when the effort pays off.
-
Dec 15, 2025
Debugging PHPUnit tests in a Docker environment with PhpStorm is one of the most frustrating parts of PHP development. Configuration usually fails because of XDEBUG_MODE, incorrect path mapping, or a remote interpreter that was never set up correctly. This guide shows the complete path, from installing Xdebug to running coverage reports.
-
Dec 11, 2025
The automatic property-by-property comparison of assertEquals() fails for value objects with their own business definition of equality. assertObjectEquals() and custom comparator classes solve this by using the class's own real comparison logic.
-
Dec 3, 2025
Tests that only ever run locally do not protect a project. Only integration into CI/CD turns test automation into a quality gate: every pull request is checked automatically, coverage reports are stored as artifacts, and failures are reported where they happen, in the code, not first at deploy time. This article shows the complete CI/CD integration of PHPUnit for both major platforms.
-
Nov 28, 2025
PHPUnit 11 is not an incremental update. It removes docblock annotations in favor of native PHP attributes, tightens coverage configuration, fundamentally changes the mock system, and sets PHP 8.1 as the minimum requirement. Anyone migrating has to change more than just the version number in composer.json.
-
Nov 24, 2025
80% line coverage sounds good. But line coverage says nothing about whether the right cases are being tested. A branch that gets executed for one particular input counts as covered, no matter whether the other branch is ever tested. Coverage is a tool, not a goal. Anyone who treats it as a vanity metric ends up optimizing the number instead of the quality.