Skip to content

test: strict PHPUnit config, PCOV coverage and Infection mutation tests#218

Merged
Morgy93 merged 4 commits into
mainfrom
improve-phpunit-setup
Jul 4, 2026
Merged

test: strict PHPUnit config, PCOV coverage and Infection mutation tests#218
Morgy93 merged 4 commits into
mainfrom
improve-phpunit-setup

Conversation

@Morgy93

@Morgy93 Morgy93 commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces comprehensive improvements to automated testing, focusing on code coverage and mutation testing for the MageForge module. It adds support for running mutation tests with Infection, enhances code coverage support using PCOV, and updates the CI workflow to test across multiple PHP versions and publish detailed reports. Several scripts and configuration files are updated or added to streamline these processes for both local development and CI.

Testing enhancements:

  • Added support for mutation testing using Infection, including configuration and scripts to run mutation tests locally and in CI. (infection.json5, composer.json, .ddev/commands/web/infection, [1] [2] [3] [4] [5] [6]
  • Improved code coverage support by integrating PCOV, updating scripts to enable coverage per run, and providing clear instructions and reporting. (.ddev/commands/web/phpunit, .ddev/php/pcov.ini, .ddev/web-build/Dockerfile.pcov, [1] [2] [3] [4]

Continuous integration (CI) improvements:

  • Updated the GitHub Actions workflow to:
    • Run tests on multiple PHP versions (8.3, 8.4)
    • Collect and publish code coverage and mutation testing reports as workflow artifacts and job summaries
    • Add a separate job for mutation testing with Infection (.github/workflows/phpunit.yml, .github/workflows/phpunit.ymlL8-R122)

Configuration improvements:

  • Enhanced PHPUnit configuration for stricter and more informative test execution, including random execution order, strictness about output and global state, and detailed reporting on warnings and deprecations. (phpunit.xml.dist, phpunit.xml.distL6-R29)

Composer updates:

  • Added Infection and its extension installer as dev dependencies, and introduced new Composer scripts for running tests, coverage, and mutation analysis. (composer.json, [1] [2] [3]

…ting

- phpunit.xml.dist: random execution order, fail on risky/warning/empty
  suite, strict output checks, details on deprecations/notices/warnings
- PCOV in the DDEV web image (disabled by default, enabled per run to
  avoid the opcache JIT warning); `ddev phpunit --coverage` generates
  text, HTML and Clover reports
- Infection mutation testing via `ddev infection` / composer test:mutation
- CI: PHP 8.3/8.4 matrix, coverage summary + artifact, mutation job

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 4, 2026 19:14

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 automated testing setup by tightening PHPUnit configuration, adding mutation testing via Infection, and improving coverage reporting (PCOV) locally (DDEV) and in CI.

Changes:

  • Made PHPUnit execution stricter (random order, fail on risky/warnings, stricter output/global-state rules) and refined source inclusion/exclusion.
  • Added Infection mutation testing configuration plus local DDEV commands to run mutation tests and coverage with PCOV.
  • Updated the GitHub Actions PHPUnit workflow to run across PHP 8.3/8.4, generate coverage artifacts/summaries, and add a dedicated mutation-testing job.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
phpunit.xml.dist Adds stricter PHPUnit defaults and source filtering.
infection.json5 Introduces Infection configuration and report outputs.
composer.json Adds Infection dependency and test/coverage/mutation scripts.
.gitignore Ignores generated testing reports.
.github/workflows/phpunit.yml Runs PHPUnit matrix with optional coverage and adds mutation job.
.ddev/web-build/Dockerfile.pcov Installs PCOV in the DDEV web image for faster coverage runs.
.ddev/php/pcov.ini Disables PCOV by default (opt-in per run).
.ddev/commands/web/phpunit Adds --coverage flag support and PCOV-enabled coverage runs.
.ddev/commands/web/infection Adds a DDEV command to run Infection with PCOV-enabled initial test run.

Comment thread infection.json5
Comment thread phpunit.xml.dist
Morgy93 and others added 2 commits July 4, 2026 21:18
- shellcheck SC2250: brace all variable references in the phpunit command
- hadolint: ignore .ddev/web-build/** — DDEV Dockerfile fragments have no
  FROM and use sudo by design
- quote the apt package argument in Dockerfile.pcov

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 4, 2026 19:28

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

Copilot reviewed 9 out of 10 changed files in this pull request and generated 7 comments.

Comment thread infection.json5
Comment thread .ddev/commands/web/phpunit
Comment thread .ddev/commands/web/infection
Comment thread composer.json
Comment thread .github/workflows/phpunit.yml
Comment thread .github/workflows/phpunit.yml
Comment thread .github/workflows/phpunit.yml
PHPUnit's text report writes with a bare file_put_contents and only
works if the Clover/HTML writers created reports/ first; drop that
ordering dependence.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Morgy93 Morgy93 merged commit a8079c7 into main Jul 4, 2026
20 checks passed
@Morgy93 Morgy93 deleted the improve-phpunit-setup branch July 4, 2026 19:56
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