Skip to content

feat: allow configuring Pest configuration discovery paths - #21

Merged
MrPunyapal merged 3 commits into
pestphp:5.xfrom
wanted80:fix/configure-pest-discovery
Oct 6, 2026
Merged

MrPunyapal merged 3 commits into
pestphp:5.xfrom
wanted80:fix/configure-pest-discovery

Conversation

@wanted80

@wanted80 wanted80 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

PestFileDiscoverer currently searches PHPStan's analysis paths and the entire working directory recursively for Pest.php files. Large data directories and mounted storage beneath the project root are therefore traversed even when they are outside PHPStan's analysis paths.

Add an optional pest.configPaths setting so projects can restrict configuration discovery to their test directories:

parameters:
    pest:
        configPaths:
            - %currentWorkingDirectory%/tests

The setting controls Pest.php discovery only. PHPStan continues to analyse its configured paths. Ancestor Pest.php files are still discovered up to the project root, and discovery remains memoized.

  • null preserves the current default search through analysis paths and the working directory.
  • A list searches only those paths and their ancestors.
  • An empty list disables configuration discovery.

The parameter has a schema and is passed through the existing discovery service. Tests cover restricted paths, multiple directories, an empty list, the unchanged default, ancestor configuration and real PHPStan service wiring.

Validation:

  • composer test:lint: Rector and Pint pass.
  • composer test:types: PHPStan at maximum level reports no errors.
  • composer test:unit: 523 passed tests and two notices in unchanged PHPStan Scope mock tests; exit code 0.
  • Focused discovery tests: 12 passed, 26 assertions.

Add optional pest.configPaths with a nullable list schema and wire it into
PestFileDiscoverer. Explicit paths replace analysis paths and the automatic
working-directory scan, allowing projects to avoid large data directories
and mounted storage during Pest configuration discovery.

Preserve existing discovery when unset, retain ancestor configuration and
memoization, and allow an empty list to disable configuration discovery.
Cover restricted and multiple paths, empty lists, default behavior, and
PHPStan dependency injection with regression tests.
@MrPunyapal

Copy link
Copy Markdown
Member

Could we use a unique temporary directory here instead of the fixed pest-discovery-container path?

The test suite runs with pest --parallel, so a fixed directory could be shared by concurrent test runs or leave state behind between runs.

@wanted80

wanted80 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

I hope I got it right, because my brain is a little fried tonight. XD

Use null coalescing when resolving import aliases so Rector 2.7.0 and PHPStan both accept the discovery code.

Replace Scope mocks without expectations with stubs to eliminate PHPUnit notices. Validated the full Composer test suite with fresh dependencies: 525 tests and 646 assertions.
@MrPunyapal
MrPunyapal merged commit 642d827 into pestphp:5.x Oct 6, 2026
10 checks passed
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.

2 participants