feat: improve unit tests#219
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR strengthens MageForge’s QA setup by adding a broad set of new unit tests around core services/models and by introducing basic coverage/mutation-quality “ratchets” in local tooling and CI.
Changes:
- Added new PHPUnit unit tests for multiple services (theme building/cleaning, Hyvä scanning, node/grunt helpers) and supporting models/exceptions.
- Added a lightweight Clover line-coverage checker and wired it into CI and local
ddev phpunit --coverageruns. - Enforced a minimum covered MSI threshold in Infection configuration.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/Service/ThemeSuggesterTest.php | New tests for ThemeSuggester suggestion logic and guards. |
| tests/Unit/Service/ThemeCleanerTest.php | New tests for ThemeCleaner deletion/dry-run/verbose behaviour. |
| tests/Unit/Service/ThemeBuilder/BuilderPoolTest.php | New tests for builder selection and pool behaviour. |
| tests/Unit/Service/ThemeBuilder/BuilderFactoryTest.php | New tests for builder registration and factory lookup/exception. |
| tests/Unit/Service/SymlinkCleanerTest.php | New tests for symlink removal behaviour in developer mode. |
| tests/Unit/Service/StaticContentDeployerTest.php | New tests for conditional static content deployment. |
| tests/Unit/Service/StaticContentCleanerTest.php | New tests for conditional pre-build cleaning behaviour. |
| tests/Unit/Service/StandardThemeBuilderTest.php | New tests for build orchestration and step tracking. |
| tests/Unit/Service/NodePackageManagerTest.php | New tests for npm install/ci and outdated package reporting. |
| tests/Unit/Service/Hyva/ModuleScannerTest.php | New tests for module scanning recursion/exclusions and metadata parsing. |
| tests/Unit/Service/Hyva/IncompatibilityDetectorTest.php | Expanded coverage for extension parsing and uppercase extension scanning. |
| tests/Unit/Service/Hyva/CompatibilityCheckerTest.php | New tests for summary aggregation and output formatting helpers. |
| tests/Unit/Service/GruntTaskRunnerTest.php | New tests for grunt execution/verbosity and error handling. |
| tests/Unit/Service/DependencyCheckerTest.php | New tests for dependency validation and prompt-driven remediation. |
| tests/Unit/Service/CacheCleanerTest.php | New tests for cache cleaning command execution and verbosity. |
| tests/Unit/Model/ThemePathTest.php | New tests for theme path resolution (frontend/adminhtml fallback). |
| tests/Unit/Model/ThemeListTest.php | New tests for theme list passthrough behaviour. |
| tests/Unit/Model/Config/Source/ToolbarPositionTest.php | New tests for toolbar position option source output. |
| tests/Unit/Model/Config/Source/InspectorThemeTest.php | New tests for inspector theme option source output. |
| tests/Unit/Exception/FetchLatestVersionExceptionTest.php | New tests for exception inheritance/message behaviour. |
| tests/coverage-checker.php | New script to fail builds when Clover line coverage drops below a threshold. |
| infection.json5 | Added minCoveredMsi threshold to enforce mutation-quality floor. |
| .github/workflows/phpunit.yml | CI step added to enforce minimum line coverage when coverage is enabled. |
| .ddev/commands/web/phpunit | Local coverage runs now invoke the coverage checker (full-suite only). |
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 introduces a comprehensive set of improvements to the project's quality assurance and testing infrastructure. The main changes include the addition of extensive new unit tests for several core classes, as well as the enforcement of stricter code coverage requirements both locally and in CI. These updates will help ensure higher code quality and reliability as the codebase evolves.
Testing improvements:
FetchLatestVersionException(tests/Unit/Exception/FetchLatestVersionExceptionTest.php)InspectorTheme(tests/Unit/Model/Config/Source/InspectorThemeTest.php)ToolbarPosition(tests/Unit/Model/Config/Source/ToolbarPositionTest.php)ThemeList(tests/Unit/Model/ThemeListTest.php)ThemePath(tests/Unit/Model/ThemePathTest.php)CacheCleaner(tests/Unit/Service/CacheCleanerTest.php)DependencyChecker(tests/Unit/Service/DependencyCheckerTest.php)GruntTaskRunner(tests/Unit/Service/GruntTaskRunnerTest.php)Code coverage enforcement:
tests/coverage-checker.phpafter the test suite, and only for full-suite runs locally. (.ddev/commands/web/phpunit,.github/workflows/phpunit.yml) [1] [2]infection.json5to fail the run if mutation coverage drops below this floor, supporting a quality ratchet as the suite improves.These changes together will help maintain and improve code quality by catching regressions early and providing better test coverage for critical components.