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

Update PHP tests to follow WP core conventions. #666

Open
matiasbenedetto opened this issue Jun 3, 2024 · 2 comments
Open

Update PHP tests to follow WP core conventions. #666

matiasbenedetto opened this issue Jun 3, 2024 · 2 comments

Comments

@matiasbenedetto
Copy link
Contributor

matiasbenedetto commented Jun 3, 2024

What?

Update PHP tests to follow WP core conventions.
Reference docs: https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#test-classes
Reference source: https://github.com/WordPress/wordpress-develop/tree/trunk/tests/phpunit/tests/blocks

Why?

Some of the plugin tests in the plugin don't follow that convention.

Expected

All tests should follow the same convention.

@vcanales
Copy link
Member

vcanales commented Jun 3, 2024

I find it unpleasant that we — the WordPress Project in general — have decided to go with CamelCase filenames for tests when on the style guide we're giving emphasis to consistent naming.

In essence, https://make.wordpress.org/docs/style-guide/formatting/filenames/#consistent-naming versus https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#test-classes

If we were to vote on this, I'd go with https://make.wordpress.org/docs/style-guide/formatting/filenames, namely hyphenated lower case names, instead of a different file naming convention for tests.

@pbking
Copy link
Contributor

pbking commented Jun 3, 2024

Yes, I agree with the hyphenated names. The camel case feels wrong surrounded by consistency everywhere else.

I'm not a fan of the WordPress testing organization; one function per file/class, etc. I think the inconsistency started with the "WordPress organization style" was introduced, the 1:1 class/test was what was there initially. I'm trying to figure out of that just because "I've always done it differently" or of there's some other reason I'm not a fan of that structure. I learned to have a 1:1 relationship between test classes and what's tested as that seems an easier way to use TDD which is where I find value in tests while testing-after-development to ensure the code does what you expect which seems to be where this structure offers the most value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants