PHPUnit: Guides and Practical Know-how | Page 7 | mironsoft Blog
PHPUnit
-
Jul 10, 2025
A test that checks whether a message landed on a bus says nothing about whether the associated handler does the right thing. With InMemoryTransport and TraceableMessageBus, Symfony Messenger handlers can be tested synchronously, deterministically, and without RabbitMQ or Redis in the pipeline.
-
Jul 8, 2025
A store-scope bug often only shows up in production because tests only ever exercise the default store. Mocking ScopeConfigInterface deliberately covers store and website differences without maintaining real database fixtures for every store.
-
Jul 1, 2025
The most common experience in PHP projects: tests are hard to write because the production code makes them hard. Dependencies instantiated directly, global state, too many responsibilities crammed into one class. Testability is not a random byproduct, it is the result of concrete design decisions made in the production code.
-
Jun 24, 2025
Magento 2 ships its own test infrastructure that differs substantially from a standard PHPUnit project. If you want to run integration tests directly from PHPStorm, see coverage reports in the IDE, and debug individual test methods with a single click, you need specific configuration, which this article covers in full.
-
Jun 18, 2025
An HTML coverage report is good for a bird's-eye view, but poor for actual work. PhpStorm shows test coverage directly in color inside the editor gutter, so uncovered lines are visible exactly where you are coding.
-
Jun 18, 2025
A slow, unstructured test suite is not a test suite, it is a drag on the team. This checklist surfaces every place where PHPUnit setups lose time, maintainability and developer trust, and gives a directly actionable step for each point.
-
Jun 13, 2025
A test that turns red on every implementation change without the observable behavior having changed is not a test, it is an obstacle. Overspecified mocks, testing your own classes through mocks, spy abuse, and expectation overload are the most common causes of brittle PHPUnit suites that create more maintenance effort than confidence.
-
May 29, 2025
Green tests do not mean the code is safe. In many teams, tests only get a superficial look in review, whether they run, whether coverage numbers add up. Yet it is entirely different criteria that decide whether a PHPUnit test provides real protection against regressions or merely fakes safety.
-
May 28, 2025
Magento plugins and observers are powerful extension points, but their tight coupling to the Magento ObjectManager makes them hard to test. With the right refactoring approach, the core logic of any plugin or observer can be extracted and tested in isolation with PHPUnit, entirely without a Magento bootstrap.
-
May 19, 2025
Running tests directly in the IDE with a single click or keyboard shortcut, without ever opening a console, is a productivity gain that quickly becomes second nature. PhpStorm supports PHPUnit for Docker-based Magento setups completely, as long as the remote interpreter and the run configuration are set up correctly. This article walks through the full setup process.