Handling of configuration files

Open
#134 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
php
Domain
testing-qa

Research direction

Start by reviewing PHPUnit 10's configuration-file validation and how PHPUnit selects configuration files across versions. The issue names no repository files, tests, or entry points; a finished solution would need an agreed approach for handling version-specific settings without causing otherwise successful test runs to fail.

Written by the indexing model from the issue text.

Description

Type: question

PHPUnit 10 brings both several changes to the configuration file and a misfeature of causing phpunit to exit with a non-zero status if the config file does not strictly validate.

So, for example, if you had been relying on convert{X}ToExceptions="true", you might want to set displayDetailsOnTestsThatTrigger{X}="true" and failOn{X}="true" for PHPUnit 10 to maintain that behavior going forward. But unless you also remove convert{X}ToExceptions="true", changing the behavior for runs with earlier versions of PHP, PHPUnit 10 will whine about not recognizing the old setting and will exit with a failure status even if all actual tests pass.

I don't know what the best way around this might be.

Simplest might be to provide a wrapper script that, if not passed -c or --configuration or --no-configuration, looks for various config file names and picks the best one for the current version of PHPUnit to set --configuration before execing phpunit. For example, it might check for any "phpunit.{VER}.xml.dist" and pick the one with the highest {VER} that's not greater than PHPUnit's own version.

A little fancier might be a wrapper that determines the configuration file in the same way PHPUnit would, copies it to a temporary file while stripping a predefined list of settings based on the PHPUnit version, and calls phpunit with --configuration pointing to the temporary file.

Unfortunately PHPUnit doesn't provide any way to hook into its own code to handle things more directly. There might still be ways, but they'd be fragile.

Dominant language
PHP
Stars
189
Forks
13
PR merge metrics
No merged PRs in 30d

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Yoast/PHPUnit-Polyfills

All issues in Yoast/PHPUnit-Polyfills

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.