PHPUnit: Guides and Practical Know-how | Page 8 | mironsoft Blog
PHPUnit
-
May 12, 2025
CLI commands are often the least tested part of a PHP application. Yet these are exactly the commands that drive cron jobs, migrations, deployments and critical batch operations. The exit code is the only communication channel between a process and the calling system, and it has to be correct so CI pipelines and orchestrators can react to failures.
-
May 10, 2025
Magento GraphQL resolvers implement a simple, well-defined interface that can be tested directly with PHPUnit, without ever building the complete schema, once field resolution and data fetching are cleanly separated.
-
May 2, 2025
Using PHPUnit in PhpStorm is trivial when PHP is installed locally. With Docker interpreters, Magento-specific bootstrap files and integration tests that require a running database, the configuration becomes more complex. This guide shows how to solve each of these cases cleanly.
-
Apr 22, 2025
Repository tests with mocks check the wrong layer. A mock repository cannot detect a SQL syntax problem, an index problem, or an N+1 bug. Real database access in tests is expensive, but irreplaceable at the right spots. The art lies in knowing exactly where those spots are and how to implement database isolation reliably.
-
Apr 18, 2025
PHP's native SoapClient and similar proprietary legacy interfaces are hard to handle with classic PHPUnit mocks, because they open a network connection in the constructor and ship final declared methods. A thin wrapper interface solves exactly this problem and makes ERP or inventory system integrations in Magento projects cleanly testable.
-
Apr 13, 2025
Magento cron jobs don't need to be tested through the full cron execution: by calling the job class directly and separating scheduling from business logic, every cron job can be treated as an ordinary PHPUnit test.
-
Apr 9, 2025
Magento consumers run asynchronously against RabbitMQ, yet the actual processing logic behind them can be tested fully synchronously without a running broker once the consumer class and the domain logic are cleanly separated.
-
Apr 9, 2025
Snapshot tests sound tempting: run once, save the result, done. In practice, though, they quickly turn into a maintenance burden if you do not exactly understand which scenarios they fit and how much discipline the team needs to apply.
-
Apr 1, 2025
SearchCriteria queries, collection filters and EAV attributes are the three most common data access patterns in Magento, and at the same time the three most common places where tests are either missing or structured incorrectly. This article shows which test type fits which access pattern and how to secure each one correctly.
-
Mar 31, 2025
A GraphQL API that works in development mode is not yet a production-ready API. Performance traps, security gaps and missing observability only surface under load, exactly when there is little room to react. This checklist closes those gaps before they become a problem.