Skip to content

feat: improve unit tests#219

Merged
Morgy93 merged 2 commits into
mainfrom
increase-test-coverage
Jul 5, 2026
Merged

feat: improve unit tests#219
Morgy93 merged 2 commits into
mainfrom
increase-test-coverage

Conversation

@Morgy93

@Morgy93 Morgy93 commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

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:

  • Added new unit tests for the following classes to improve test coverage and reliability:
    • 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:

  • Enforced a minimum code coverage threshold of 20% for line coverage in both local and CI runs by running tests/coverage-checker.php after the test suite, and only for full-suite runs locally. (.ddev/commands/web/phpunit, .github/workflows/phpunit.yml) [1] [2]
  • Set a minimum Mutation Score Indicator (MSI) of 90% in infection.json5 to 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.

Copilot AI review requested due to automatic review settings July 5, 2026 07:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --coverage runs.
  • 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).

Comment thread .ddev/commands/web/phpunit
Comment thread tests/Unit/Service/ThemeSuggesterTest.php
Comment thread tests/Unit/Service/GruntTaskRunnerTest.php
@Morgy93 Morgy93 merged commit 408e8a1 into main Jul 5, 2026
20 checks passed
@Morgy93 Morgy93 deleted the increase-test-coverage branch July 5, 2026 07:23
@github-actions github-actions Bot mentioned this pull request Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants