You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the configure command is run on a plugin being created in a subdirectory of a larger project (e.g., put into plugins inside of a repo that has wp-content as its root), the option to use a composer.json file in a parent directory (e.g., wp-content/composer.json) does not copy the autoloader configuration to the parent Composer file. Additionally, when autoloading is hoisted to a parent context, automated tests will fail because the autoloader isn't being loaded in the plugin in a test context (rather than the plugin itself loading the autoloader file, it is assumed to be loaded already via an mu-plugins loader or similar).
Steps to Reproduce
Create a new WordPress plugin using this repo and select the options for it to be installed in a subdirectory of a larger project and to use the parent Composer configuration, then try running unit tests and observe that they fail due to not being able to resolve classes by name and autoloader.
Recommended Fix
When configuring a new plugin, if the option is selected to use the parent Composer configuration, copy over the autoload and autoload-dev configuration from the plugin to the parent composer.json. Additionally, either programmatically include a require_once to the autoloader in the plugin's tests/bootstrap.php file based on the configuration of the vendor directory in the parent composer.json, or prompt the user to do so themselves based on where/how they have configured the autoloader.
The text was updated successfully, but these errors were encountered:
Issue
When the configure command is run on a plugin being created in a subdirectory of a larger project (e.g., put into
plugins
inside of a repo that haswp-content
as its root), the option to use acomposer.json
file in a parent directory (e.g.,wp-content/composer.json
) does not copy the autoloader configuration to the parent Composer file. Additionally, when autoloading is hoisted to a parent context, automated tests will fail because the autoloader isn't being loaded in the plugin in a test context (rather than the plugin itself loading the autoloader file, it is assumed to be loaded already via an mu-plugins loader or similar).Steps to Reproduce
Create a new WordPress plugin using this repo and select the options for it to be installed in a subdirectory of a larger project and to use the parent Composer configuration, then try running unit tests and observe that they fail due to not being able to resolve classes by name and autoloader.
Recommended Fix
When configuring a new plugin, if the option is selected to use the parent Composer configuration, copy over the
autoload
andautoload-dev
configuration from the plugin to the parentcomposer.json
. Additionally, either programmatically include arequire_once
to the autoloader in the plugin'stests/bootstrap.php
file based on the configuration of the vendor directory in the parentcomposer.json
, or prompt the user to do so themselves based on where/how they have configured the autoloader.The text was updated successfully, but these errors were encountered: