Skip to content

PHPUnit bootstrap fatals on contrib test-namespace/dir case mismatch (should skip gracefully) #387

Description

@bbrala

Companion to GitLab issue #3540378 (reported by alex.skrypnyk).

Problem

Running vendor/bin/rector --clear-cache --dry-run on a project that has a contrib module with a case-mismatched test namespace aborts the entire run:

Error: [ERROR] RecursiveDirectoryIterator::__construct(/app/web/modules/contrib/webform/modules/webform_cards/tests/src/FunctionalJavaScript): Failed to open directory: No such file or directory

Root cause: config/drupal-phpunit-bootstrap-file.php iterates test directories derived from namespaces. webform_cards declares Drupal\Tests\webform_cards\FunctionalJavascript (lowercase "s") while the directory is FunctionalJavaScript (uppercase "S"), so the iterator points at a non-existent path and throws. One bad contrib module takes down the whole rector run.

Proposed fix

In config/drupal-phpunit-bootstrap-file.php, guard the directory iteration with an is_dir() check (or wrap in try/catch) and skip + emit a clear warning for the offending path instead of fataling. The actual namespace bug is the contrib module's to fix (see webform #3441905), but drupal-rector shouldn't hard-fail the entire run because of it.

Related: #3441905.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions