Skip to content

Conversation

@maks-oleksyuk
Copy link

Summary

This pull request introduces support for passing the --configuration argument to the Pest Type Coverage Plugin, enabling it to correctly detect and load custom PHPUnit configuration files.

Previously, the plugin always relied on default configuration discovery, ignoring the --configuration flag. This made it impossible to specify a custom XML configuration file when running Pest with type coverage enabled.

What’s Changed

  • src/Plugin.php

    • Added logic to extract the --configuration argument (if present) from the CLI arguments.
    • Passed the detected argument into ConfigurationSourceDetector::detect() for accurate configuration loading.
  • src/Support/ConfigurationSourceDetector.php

    • Updated the detect() method to accept an optional $arguments array.
    • Adjusted the internal Builder initialization to use the provided arguments.

Why This Matters

This enhancement improves compatibility with projects that use custom PHPUnit XML configuration paths, ensuring that type coverage detection respects all settings defined in those files (e.g., custom source directories, filters, or test suites).

It brings the behavior of the Pest Type Coverage Plugin in line with how PHPUnit and Pest natively handle CLI configuration flags

Example Usage

./vendor/bin/pest --type-coverage --configuration=config/utils/phpunit.xml

The plugin now correctly reads and applies the configuration from the provided XML file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant