Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpcs and phpunit are not running from the project 'root' #114

Open
benpbolton opened this issue Dec 12, 2024 · 0 comments
Open

phpcs and phpunit are not running from the project 'root' #114

benpbolton opened this issue Dec 12, 2024 · 0 comments
Labels
ci/cd PR checks, deploys, automation php Requires understanding PHP

Comments

@benpbolton
Copy link
Member

benpbolton commented Dec 12, 2024

Description of the bug

While working on #111 , we learned that the default composer test will fail after initial configure due to the current structure of navigating to cd plugins/[folder] before running phpcs or phpunit and the resulting folder not having proper .phpcs.xml (prefixes, names, etc) nor a proper phpunit.xml.

Steps To Reproduce

  1. Clone this repo
  2. run yes '' | php ./configure.php --project_name=cwp --author_name=cwp [email protected] (accepting all defaults)
  3. run composer install
  4. run composer test
  5. Observe failures

Additional Information

  • Ensure plugin is cloned, scaffolded, search-replaced, config files generated so that when composer test is run it's working correctly.
  • Ensure theme and plugin namespaces are just the name of the theme or plugin, without the Alley\WP\ prefix, e.g., Example_Plugin not Alley\WP\Example_Plugin. Ensure this is universally applied, including in template files for the scaffolder in the plugin.
  • Remove ./plugin-templates/ in .phpcs.xml as part of scaffolding as it isn't necessary after the configure script has been run.
  • Add a new block to .phpcs.xml disabling the same check that was disabled in ./plugin-templates/ but for the plugin's blocks folder instead.
  • Ensure phpunit configuration is present in the plugin folder after running the configure script.
  • Ensure that the xsi:noNamespaceSchemaLocation property points to ../../mu-plugins/vendor/phpunit/phpunit/phpunit.xsd for both the plugin and the theme, and that this is client-mu-plugins instead of mu-plugins for a VIP install.
  • Ensure autoloader is properly being loaded in the plugin and theme so that tests pass.
  • Ensure that Composer autoloader configuration is correct - for tests it should be PSR-4 format, not WordPress autoloader format.
  • Ensure theme files and tests are added to the autoloader configuration now that create-wordpress-theme includes PHP components.
@benpbolton benpbolton added the bug Something isn't working label Dec 12, 2024
@kevinfodness kevinfodness added ci/cd PR checks, deploys, automation php Requires understanding PHP labels Feb 19, 2025
@kevinfodness kevinfodness removed the bug Something isn't working label Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/cd PR checks, deploys, automation php Requires understanding PHP
Projects
None yet
Development

No branches or pull requests

2 participants