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: Include the test directory #48754

Open
wants to merge 9 commits into
base: trunk
Choose a base branch
from

Conversation

t-hamano
Copy link
Contributor

@t-hamano t-hamano commented Mar 5, 2023

What?

This PR adds the root-level test directory as a check target for PHPCS. At the same time, I added theme-specific rules and fix lint errors.

Why?

Since the test directory already contains PHP files, I think it would make sense to include them.

How?

The existing PHPCS rule causes the following error in the PHP files that the theme has:

  • Squiz.Commenting.FunctionComment.Missing: Missing doc comment for function xxxxx()
  • Squiz.Commenting.FileComment.Missing: Missing file doc comment
  • Squiz.Commenting.FileComment.WrongStyle: You must use "/**" style comments for a file comment

These rules are also excluded in the Theme Check plugin, so I excluded these rules as well. Then I fixed the remaining errors.

Testing Instructions

In PHP files under the test directory, make changes that do not follow the rules. For example, remove the space after the opening parenthesis.

Run npm run lint:php and confirm that a Lint error occurs.

@t-hamano t-hamano added the [Type] Code Quality Issues or PRs that relate to code quality label Mar 5, 2023
@t-hamano t-hamano self-assigned this Mar 5, 2023
@t-hamano t-hamano marked this pull request as ready for review March 5, 2023 03:26
@github-actions
Copy link

github-actions bot commented Mar 5, 2023

Flaky tests detected in 2a02183.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11517256362
📝 Reported issues:

@gziolo gziolo added the Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts label Mar 5, 2023
@gziolo
Copy link
Member

gziolo commented Mar 19, 2023

@anton-vlasenko and @hellofromtonya, you worked on similar tasks so you might want to have a look.

It looks like a step in the right direction to me.

@gziolo gziolo added the [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. label Mar 19, 2023
@anton-vlasenko
Copy link
Contributor

anton-vlasenko commented Mar 23, 2023

@gziolo I don't mind including the tests directory. My only concern is that the PHPUnit tests in Gutenberg should be checked against the same rules as those in Core.
My pull request solves the issue of identical rule sets between Core and Gutenberg, but it doesn't affect the test directory.

@t-hamano
Copy link
Contributor Author

Update:

I have discovered that the test directory has been updated to conform to current coding standards in #50656.
Therefore, I have changed this PR to simply add the test directory to phpunit.xml.dist.

This will ensure that when composer lint is run, the test directory will also be covered.

Copy link

github-actions bot commented Mar 2, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: t-hamano <[email protected]>
Co-authored-by: gziolo <[email protected]>
Co-authored-by: anton-vlasenko <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants