-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Make fonts test files use Core approach #53856
Conversation
* Moves the files into phpunit/tests/ directory to match Core. * Removes the `-test.php` suffix from each test file. * Adds the directive to find the test files in phpunit/tests/ (to match how Core does it). * Adds GUTENBERG_DIR_TESTDATA and GUTENBERG_DIR_TESTFIXTURES constants to make it easier on tests to point to these locations.
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ phpunit/bootstrap.php ❔ phpunit/multisite.xml ❔ phpunit/tests/fonts-api/base.php ❔ phpunit/tests/fonts-api/bc-layer/base.php ❔ phpunit/tests/fonts-api/bc-layer/bc-layer-tests-dataset.php ❔ phpunit/tests/fonts-api/bc-layer/gutenbergFontsApiBcLayer/isDeprecatedStructure.php ❔ phpunit/tests/fonts-api/bc-layer/gutenbergFontsApiBcLayer/migrateDeprecatedStructure.php ❔ phpunit/tests/fonts-api/bc-layer/wpRegisterWebfonts.php ❔ phpunit/tests/fonts-api/bc-layer/wpWebfonts/getAllWebfonts.php ❔ phpunit/tests/fonts-api/bc-layer/wpWebfonts/getFontSlug.php ❔ phpunit/tests/fonts-api/bc-layer/wpWebfonts/getRegisteredWebfonts.php ❔ phpunit/tests/fonts-api/bc-layer/wpWebfonts/registerWebfont.php ❔ phpunit/tests/fonts-api/wp-fonts-tests-dataset.php ❔ phpunit/tests/fonts-api/wpDeregisterFontFamily.php ❔ phpunit/tests/fonts-api/wpDeregisterFontVariation.php ❔ phpunit/tests/fonts-api/wpEnqueueFontVariations.php ❔ phpunit/tests/fonts-api/wpEnqueueFonts.php ❔ phpunit/tests/fonts-api/wpFonts.php ❔ phpunit/tests/fonts-api/wpFonts/add.php ❔ phpunit/tests/fonts-api/wpFonts/addFontFamily.php ❔ phpunit/tests/fonts-api/wpFonts/addVariation.php ❔ phpunit/tests/fonts-api/wpFonts/dequeue.php ❔ phpunit/tests/fonts-api/wpFonts/doItem.php ❔ phpunit/tests/fonts-api/wpFonts/doItems.php ❔ phpunit/tests/fonts-api/wpFonts/enqueue.php ❔ phpunit/tests/fonts-api/wpFonts/getEnqueued.php ❔ phpunit/tests/fonts-api/wpFonts/getProviders.php ❔ phpunit/tests/fonts-api/wpFonts/getRegistered.php ❔ phpunit/tests/fonts-api/wpFonts/query.php ❔ phpunit/tests/fonts-api/wpFonts/registerProvider.php ❔ phpunit/tests/fonts-api/wpFonts/remove.php ❔ phpunit/tests/fonts-api/wpFonts/removeFontFamily.php ❔ phpunit/tests/fonts-api/wpFonts/removeVariation.php ❔ phpunit/tests/fonts-api/wpFontsProviderLocal.php ❔ phpunit/tests/fonts-api/wpFontsResolver/addMissingFontsToThemeJson.php ❔ phpunit/tests/fonts-api/wpFontsResolver/enqueueUserSelectedFonts.php ❔ phpunit/tests/fonts-api/wpFontsResolver/registerFontsFromThemeJson.php ❔ phpunit/tests/fonts-api/wpFontsUtils/convertFontFamilyIntoHandle.php ❔ phpunit/tests/fonts-api/wpFontsUtils/convertVariationIntoHandle.php ❔ phpunit/tests/fonts-api/wpFontsUtils/getFontFamilyFromVariation.php ❔ phpunit/tests/fonts-api/wpFontsUtils/isDefined.php ❔ phpunit/tests/fonts-api/wpPrintFonts.php ❔ phpunit/tests/fonts-api/wpRegisterFontProvider.php ❔ phpunit/tests/fonts-api/wpRegisterFonts.php ❔ phpunit/tests/fonts/font-face/base.php ❔ phpunit/tests/fonts/font-face/wp-font-face-tests-dataset.php ❔ phpunit/tests/fonts/font-face/wpFontFace/generateAndPrint.php ❔ phpunit/tests/fonts/font-face/wpFontFaceResolver/getFontsFromThemeJson.php ❔ phpunit/tests/fonts/font-face/wpPrintFontFaces.php ❔ phpunit/tests/fonts/font-library/class-wp-rest-font-library-controller.php ❔ phpunit/tests/fonts/font-library/wpFontFamily/__construct.php ❔ phpunit/tests/fonts/font-library/wpFontFamily/base.php ❔ phpunit/tests/fonts/font-library/wpFontFamily/getData.php ❔ phpunit/tests/fonts/font-library/wpFontFamily/getDataAsJson.php ❔ phpunit/tests/fonts/font-library/wpFontFamily/getFontPost.php ❔ phpunit/tests/fonts/font-library/wpFontFamily/hasFontFaces.php ❔ phpunit/tests/fonts/font-library/wpFontFamily/install.php ❔ phpunit/tests/fonts/font-library/wpFontFamily/uninstall.php ❔ phpunit/tests/fonts/font-library/wpFontFamilyUtils/getFilenameFromFontFace.php ❔ phpunit/tests/fonts/font-library/wpFontFamilyUtils/hasFontMimeType.php ❔ phpunit/tests/fonts/font-library/wpFontFamilyUtils/mergeFontsData.php ❔ phpunit/tests/fonts/font-library/wpFontLibrary/getFontsDir.php ❔ phpunit/tests/fonts/font-library/wpFontLibrary/setUploadDir.php |
@@ -14,6 +14,7 @@ | |||
<testsuites> | |||
<testsuite name="default"> | |||
<directory suffix="-test.php">./phpunit/</directory> | |||
<directory suffix=".php">./phpunit/tests/</directory> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WordPress Core does it this way https://github.com/WordPress/wordpress-develop/blob/trunk/phpunit.xml.dist#L17.
I left the original <directory>
directive on purpose to:
- allow all other tests to run, until they are also moved into this Core specific
tests
directory. - avoid disruption in existing PRs.
define( 'GUTENBERG_DIR_TESTDATA', __DIR__ . '/data/' ); | ||
define( 'GUTENBERG_DIR_TESTFIXTURES', __DIR__ . '/fixtures/' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core uses DIR_TESTDATA
to point to its tests' data
directory. This is a constant that will need to be changed when merging tests into Core.
Could explore overwriting DIR_TESTDATA
instead. But there may be some tests that truly need to use Core's data
directory and contents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a constant that will need to be changed when merging tests into Core.
I'm wondering if the necessity of renaming the constant should be documented somewhere.
I can't seem to find an appropriate page in the Gutenberg developer documentation where the requirement to rename the constant could be added.
Probably, considering adding a new phpunit/README.md
file could be an option, similar to the README.md
file in the lib/
folder.
What's your opinion on this matter, @hellofromtonya?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thinking @anton-vlasenko. I'm thinking about a separate follow-up PR that updates or adds a doc page for the Gutenberg handbook.
Why separate PR?
This PR is focused on only the fonts components, rather than all of the tests. A separate scope of work can be targeted at providing testing instructions and guidance for tests that are intended to be merged into Core. I suspect there's none currently available. Thus, the handbook/docs scope of work might be more involved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, we'll want to document the new @core-merge
annotation with Core merge instructions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A separate scope of work can be targeted at providing testing instructions and guidance for tests that are intended to be merged into Core. I suspect there's none currently available. Thus, the handbook/docs scope of work might be more involved.
That's a good point, @hellofromtonya. I agree.
Doing it within the scope of another PR is fine with me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue for documenting the new @core-merge
annotation: #54041
Hey @matiasbenedetto I added you to the reviewers list to ensure you are aware of this change. Please don't feel like you have to do a review, as I know you are focused on the Font Library. |
Test ReportEnvironment
Actual Results✅ 1. When running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR LGTM (test report).
However, I have a question (please see below):
define( 'GUTENBERG_DIR_TESTDATA', __DIR__ . '/data/' ); | ||
define( 'GUTENBERG_DIR_TESTFIXTURES', __DIR__ . '/fixtures/' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a constant that will need to be changed when merging tests into Core.
I'm wondering if the necessity of renaming the constant should be documented somewhere.
I can't seem to find an appropriate page in the Gutenberg developer documentation where the requirement to rename the constant could be added.
Probably, considering adding a new phpunit/README.md
file could be an option, similar to the README.md
file in the lib/
folder.
What's your opinion on this matter, @hellofromtonya?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I like how we are getting closer to how WordPress core is structured to make the backports easier. |
Thanks! Me too :) One more step towards seamless Core merges. |
What?
Makes the fonts tests ready for Core merge by eliminating the need to rename the test files.
Why?
To make it easier to merge these tests into Core.
WordPress Core's PHPUnit tests:
tests/phpunit/tests/
directory.-test.php
to the test filename.<directory suffix=".php">
to identify where the tests are located.By moving the files into
phpunit/tests
, Gutenberg's tests will no longer need to add the-test.php
suffix to the test filenames. This means the test files will not have to be renamed when merging them into WordPress Core.How?
phpunit/tests/
-test
from each test filename.base.php
to match Core.data
andfixtures
directories.Testing Instructions
There should be no change in the number of tests that run before and after this PR.
To run all of the tests, run the following:
should produce the same results before and after this PR. (Try it on
trunk
and this PR.)For the fonts tests only, run the following:
which should produce the exact same results before and after this PR. (Try it on
trunk
and this PR.)