WordPress / create-block-theme

A WordPress plugin to create block themes
https://wordpress.org/plugins/create-block-theme/
GNU General Public License v2.0
323 stars 51 forks source link

Update PHP tests to follow WP core conventions. #666

Open matiasbenedetto opened 3 months ago

matiasbenedetto commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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.