Improve error handling for incorrect test namespaces

Created on 8 August 2025, 8 days ago

When running:

vendor/bin/rector --clear-cache --dry-run

on a Drupal project with rector/rector and palantirnet/drupal-rector, I consistently get the following error:

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

I traced this to vendor/palantirnet/drupal-rector/config/drupal-phpunit-bootstrap-file.php when it attempts to load files.

The root cause appears to be a namespace mismatch in one of the contrib modules. All test classes in webform/modules/webform_cards/tests/src/FunctionalJavaScript (note the uppercase “S” in FunctionalJavaScript) use the incorrect namespace:

Drupal\Tests\webform_cards\FunctionalJavascript

(with a lowercase “s” in FunctionalJavascript).

There is an existing issue 🐛 Tests fails because of typo in webform_cards submodule FunctionalJavaScript folder Active in the Webform project to address the namespace, but I’m wondering if palantirnet/drupal-rector should handle such cases more gracefully—perhaps by throwing a clearer error or skipping the affected test classes.

🐛 Bug report
Status

Active

Component

Code

Created by

🇦🇺Australia alex.skrypnyk Melbourne

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @alex.skrypnyk
  • 🇦🇺Australia alex.skrypnyk Melbourne
  • 🇦🇺Australia alex.skrypnyk Melbourne

    Debugging further:
    the issue is in the `drupal_phpunit_get_extension_namespaces()` where `is_dir()` is called to check if a directory exists for a specific test suite.

    When a codebase runs in Docker with volumes mounted, the `is_dir()` returns TRUE instead of FALSE. `RecursiveDirectoryIterator` is more strict and throws an error when cannot find the exact directory.

  • 🇦🇺Australia alex.skrypnyk Melbourne

    I have different way to create and then apply patches for webform in different OSes. Because it is hard to predict if git patch is `core.ignorecase=true` or `core.ignorecase=false`, the patch may or may not apply :(

    Attaching a temporary patch to skip the `webform_cards` extension altogether.

Production build 0.71.5 2024