feat: improve coverage#221
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR focuses on increasing unit test coverage and improving testability/maintainability by decoupling MageForge from Magento_Developer (and reducing reliance on Magento_Store constants), adding more injectable dependencies, and tightening CI quality gates (coverage + mutation testing).
Changes:
- Introduces
DeveloperAccessCheckerand refactors Inspector-related code to remove directMagento_Developer\Helper\Datausage and replaceScopeInterface::SCOPE_STOREwith a localInspectorConfig::SCOPE_STORE. - Refactors CLI internals for testability (e.g. extracting TTY detection; allowing HTTP client injection + timeouts in
VersionCommand). - Adds extensive unit tests across Theme Builders, Inspector hints/decorators, Node setup utilities, and multiple CLI commands; raises PHPUnit minimum coverage threshold and adjusts Infection MSI threshold.
Reviewed changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/Service/ThemeBuilder/TailwindCSS/BuilderTest.php | Adds unit coverage for TailwindCSS theme builder detect/build/watch/autoRepair paths. |
| tests/Unit/Service/ThemeBuilder/MagentoStandard/BuilderTest.php | Adds unit coverage for Magento standard theme builder flows incl. vendor themes and node setup detection. |
| tests/Unit/Service/ThemeBuilder/HyvaThemes/BuilderTest.php | Adds unit coverage for Hyvä theme builder detect/build/watch/autoRepair paths and exact messaging. |
| tests/Unit/Service/SymlinkCleanerTest.php | Adds a regression test for basename handling when directory separators are absent. |
| tests/Unit/Service/StaticContentDeployerTest.php | Adds verbose-mode messaging coverage for developer-mode skip behaviour. |
| tests/Unit/Service/NodeSetupValidatorTest.php | Adds coverage for Node setup validation/restore flows and verbose/quiet behaviours. |
| tests/Unit/Service/NodePackageManagerTest.php | Expands coverage for verbose fallbacks (npm ci → npm install) and missing lockfile behaviour. |
| tests/Unit/Service/Inspector/Cache/BlockCacheCollectorTest.php | Adds coverage for cache-metric extraction and JSON formatting. |
| tests/Unit/Service/Hyva/ModuleScannerTest.php | Expands coverage for scanner edge cases and module-info classification inputs. |
| tests/Unit/Service/Hyva/IncompatibilityDetectorTest.php | Fixes/extends test coverage for non-existent file handling with isolated mocks. |
| tests/Unit/Service/Hyva/CompatibilityCheckerTest.php | Adds coverage for showAll output behaviour. |
| tests/Unit/Service/DeveloperAccessCheckerTest.php | Adds coverage for new DeveloperAccessChecker behaviour and scope config calls. |
| tests/Unit/Service/DependencyCheckerTest.php | Adds verbose-flow assertions for dependency checks and copy/install branches. |
| tests/Unit/Model/TemplateEngine/Plugin/InspectorHintsTest.php | Adds coverage for plugin behaviour gating inspector hints by mode/config/IP allowance. |
| tests/Unit/Model/TemplateEngine/Decorator/InspectorHintsTest.php | Adds coverage for decorator injection rules and metadata escaping/structure. |
| tests/Unit/Model/TemplateEngine/Decorator/InspectorHintsFactoryTest.php | Adds coverage for factory wiring to Magento’s object manager. |
| tests/Unit/Model/TemplateEngine/Decorator/FakeVendorModuleBlock2.php | Adds a deterministic block double to stabilise module-name extraction tests. |
| tests/Unit/Model/Config/InspectorTest.php | Adds coverage for config constants/defaults. |
| tests/Unit/Console/Command/Theme/WatchCommandTest.php | Adds coverage for watch command routing, exit codes, and error messaging. |
| tests/Unit/Console/Command/Theme/TokensCommandTest.php | Adds coverage for Hyvä token generation command (local/vendor themes, verbose, failures). |
| tests/Unit/Console/Command/Theme/ListCommandTest.php | Adds coverage for list output (empty + populated) and command metadata. |
| tests/Unit/Console/Command/Theme/FakeThemeWithTitle.php | Adds a minimal ThemeInterface double for list/build/clean command tests. |
| tests/Unit/Console/Command/Theme/CleanCommandTest.php | Adds coverage for cleaning flows, dry-run, multi-theme summary, and wildcard resolution. |
| tests/Unit/Console/Command/Theme/BuildCommandTest.php | Adds coverage for build flows (verbose/non-verbose), wildcard handling, and summaries. |
| tests/Unit/Console/Command/System/VersionCommandTest.php | Adds coverage for version display + API failure modes using a mocked HTTP client. |
| tests/Unit/Console/Command/System/FakeHttpClient.php | Adds deterministic HTTP client double used by system check command tests. |
| tests/Unit/Console/Command/System/CheckCommandTest.php | Adds coverage for system diagnostics output, probing fallbacks, and decorated output rules. |
| tests/Unit/Console/Command/Hyva/CompatibilityCheckCommandTest.php | Adds coverage for Hyvä compatibility check command output and exit code behaviour. |
| tests/Unit/Console/Command/Dev/InspectorCommandTest.php | Adds coverage for inspector enable/disable/status flows and cache interactions. |
| tests/Unit/Console/Command/ConcreteTestCommand.php | Adds a concrete command subclass to expose AbstractCommand protected APIs for testing. |
| tests/Unit/Console/Command/AbstractCommandTest.php | Adds broad coverage for AbstractCommand helpers and environment sanitisation logic. |
| tests/Unit/Block/InspectorTest.php | Adds coverage for Inspector block gating logic and config value defaults. |
| src/Service/DeveloperAccessChecker.php | Introduces a framework-only replacement for Magento_Developer dev-allow checks. |
| src/Model/TemplateEngine/Plugin/InspectorHints.php | Refactors to use DeveloperAccessChecker and local scope constant. |
| src/Model/Config/Inspector.php | Adds SCOPE_STORE constant to avoid depending on Magento_Store for a string constant. |
| src/Console/Command/System/VersionCommand.php | Allows HTTP client injection for tests and adds request timeouts. |
| src/Console/Command/AbstractCommand.php | Extracts TTY detection into an overridable method to make it unit-testable. |
| src/Block/Inspector.php | Refactors to use DeveloperAccessChecker and local scope constant. |
| phpunit.xml.dist | Forces COLUMNS for deterministic SymfonyStyle wrapping in assertions. |
| infection.json5 | Adjusts min covered MSI threshold and documents rationale. |
| .github/workflows/phpunit.yml | Raises minimum line coverage threshold enforced in CI. |
| .ddev/commands/web/phpunit | Keeps local coverage enforcement threshold in sync with CI. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves testability, reduces dependencies on optional Magento modules, and tightens quality gates for code coverage. The most important changes are grouped below.
Decoupling from Optional Magento Modules
DeveloperAccessCheckerservice to replace direct usage ofMagento_DeveloperandMagento_Storedependencies for developer IP checks, allowing the codebase and its tests to function without requiring these optional modules. This service is now used in bothInspectorblock andInspectorHintsplugin, and tests were updated accordingly. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]Testability Improvements
Inspectorblock (InspectorTest.php) and a minimal concrete command for testingAbstractCommand's protected API, improving coverage and enabling easier testing of command-line behaviors. [1] [2]AbstractCommandto extract TTY detection into a protected method (isRealTtyAvailable()), making it overridable in tests for deterministic testing of terminal interactivity.Configuration and Quality Gates
SCOPE_STOREconstant toInspectorConfigto avoid depending onMagento\Store\Model\ScopeInterfacefor a simple string value, further reducing optional dependencies..github/workflows/phpunit.yml,.ddev/commands/web/phpunit, andinfection.json5to enforce stricter minimum coverage (from 20% to 78% for PHPUnit, and from 90% to 85% for mutation score indicator), reflecting improved test quality and aligning with coverage badge standards. [1] [2] [3]Configuration Consistency
phpunit.xml.distto ensure consistent output wrapping across all environments, which helps prevent test failures due to output formatting differences.Minor Improvements
VersionCommandfor easier testing and set timeouts for HTTP requests, improving testability and robustness. [1] [2]