PHPUnit: Guides and Practical Know-how | Page 10 | mironsoft Blog
PHPUnit
-
Feb 8, 2025
Some tests fail not because the tested code is broken, but because they depend on factors outside the test's control: network latency, timing windows, or external services with occasional hiccups. Retry plugins automatically rerun a failed test before marking it definitively red, and can stabilize an unstable CI pipeline in the short term. But treating retry as a permanent fix instead of a time-boxed stopgap only pushes real problems into a comfortable gray zone.
-
Feb 4, 2025
Anyone writing Magento code without tests learns during the first refactoring how fragile the dependencies really are. PHPUnit tests for repositories, service contracts and ViewModels cover the logic of the most important layers, without needing the full Magento bootstrap.
-
Jan 28, 2025
Three tests that check the same thing with only different input values are not a sign of good test coverage. They are technical debt. DataProvider solves this problem elegantly: one test method, many datasets, each one a separate, named test case. Used correctly, DataProvider reduces duplication and increases readability at the same time.
-
Jan 21, 2025
GraphQL authorization does not end at the query check. Sensitive fields such as email addresses, order histories, and admin-specific data must be secured at the field level, inside the resolver context, not just in the schema. This article shows how that works in practice.
-
Jan 14, 2025
Tests that pass individually but fail when run together are the most frustrating problem in a PHPUnit suite. Behind them almost always lies global state, missing isolation, or hidden dependencies between tests, problems that are discoverable and permanently fixable with the right methodology.
-
Jan 10, 2025
Magento unit tests without bootstrap run in seconds instead of minutes. But not every Magento class can be tested meaningfully without framework initialization. ViewModels, pure service classes, plugins performing simple data transformations and pricing logic are ideal candidates. Block rendering, layout processing and observer chains, on the other hand, need the bootstrap, and that is not a failure of the test.
-
-
Jan 2, 2025
A half-heartedly set up PHPUnit project slows down every developer workflow: missing autoload paths, no bootstrap, no separation between unit and integration tests. This tutorial shows what a clean setup looks like from the start, reproducible, team-friendly and CI-ready.