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

Fix font library unit tests nit-picks [round 2] #58612

Merged

Conversation

anton-vlasenko
Copy link
Contributor

@anton-vlasenko anton-vlasenko commented Feb 2, 2024

What?

Updates the Font Library's PHPUnit tests to comply with the WordPress Core Test coding standards and practices.

Follow-up from #58502.

WP_Test_REST_TestCase::assertErrorResponse() doesn't adhere to the coding standards, so I've created a Trac ticket to address that as well: https://core.trac.wordpress.org/ticket/60426.

Why?

To prepare the test suite for Core sync / merge, as these changes will get flagged in review. By fixing them now, it can help to reduce the review time and change requests at Core merge time.

How?

  • Removed the assignment of an empty array to $post_ids_to_delete in the Tests_Font_Family_Backwards_Compatibility class, as it's unnecessary.
  • Replaced json_encode with wp_json_encode in the mock_request method within the wpFontCollection/loadFromJson.php file to ensure consistent JSON encoding.
  • Replaced json_encode with wp_json_encode in the mock_request_missing_slug method within the wpFontCollection/loadFromJson.php file to ensure consistent JSON encoding.
  • Updated the assertion message in the test_should_get_mock_font_collection method in the wpFontLibrary/getFontCollections.php file to fix a typo in the word "Should."
  • Updated a comment in the unregister_non_existing_collection method in the wpFontLibrary/unregisterFontCollection.php file to fix a typo by changing "non existing" to "non-existing."
  • Corrected assertion message in the test_register_routes method in the wpRestFontCollectionsController.php file by adding a missing "initialized" to "intialized."
  • Corrected assertion message in the test_register_routes method in the wpRestFontCollectionsController.php file by adding a missing "initialized" to "intialized."
  • Corrected assertion message in the test_register_routes method in the wpRestFontCollectionsController.php file by adding a missing "initialized" to "intialized."
  • Updated the method name from test_create_item_santize_font_family to test_create_item_sanitize_font_family in the wpRestFontFacesController.php file to fix a typo.
  • Updated the method name from data_create_item_santize_font_family to data_create_item_sanitize_font_family in the wpRestFontFacesController.php file to fix a typo.
  • Updated the method name from test_create_item_santize_font_family to test_create_item_sanitize_font_family in the wpRestFontFacesController.php file to fix a typo.
  • Updated the method name from data_create_item_santize_font_family to data_create_item_sanitize_font_family in the wpRestFontFacesController.php file to fix a typo.
  • Updated variable names in the check_file_meta method in the wpRestFontFacesController.php file to more accurately reflect their purpose by changing $srcs to $src_attributes.
  • Updated variable names in the check_file_meta method in the wpRestFontFacesController.php file to more accurately reflect their purpose by changing $srcs to $src_attributes.

Testing Instructions

All PHPUnit tests and test code linting checks should still pass.

Testing Instructions for Keyboard

Copy link

github-actions bot commented Feb 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.

Core SVN

If you're a Core Committer, use this list when committing to wordpress-develop in SVN:

Props: antonvlasenko, get_dave.

GitHub Merge commits

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: anton-vlasenko <antonvlasenko@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>

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

Copy link

github-actions bot commented Feb 2, 2024

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/tests/fonts/font-library/fontFamilyBackwardsCompatibility.php
❔ phpunit/tests/fonts/font-library/wpFontCollection/loadFromJson.php
❔ phpunit/tests/fonts/font-library/wpFontLibrary/getFontCollections.php
❔ phpunit/tests/fonts/font-library/wpFontLibrary/unregisterFontCollection.php
❔ phpunit/tests/fonts/font-library/wpRestFontCollectionsController.php
❔ phpunit/tests/fonts/font-library/wpRestFontFacesController.php

@anton-vlasenko anton-vlasenko changed the title Fix/address nitpicks in font library unit tests round 2 Fix font library unit tests nit-picks [round 2] Feb 2, 2024
@anton-vlasenko anton-vlasenko added [Type] Code Quality Issues or PRs that relate to code quality [Feature] Font Library [Type] Enhancement A suggestion for improvement. labels Feb 2, 2024
@anton-vlasenko anton-vlasenko marked this pull request as ready for review February 2, 2024 12:40
Copy link
Contributor

@getdave getdave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fixes look good to me. Thank you.

@anton-vlasenko anton-vlasenko removed the [Type] Enhancement A suggestion for improvement. label Feb 2, 2024
@anton-vlasenko anton-vlasenko enabled auto-merge (squash) February 2, 2024 13:05
@anton-vlasenko anton-vlasenko merged commit cabd2ed into trunk Feb 2, 2024
58 of 63 checks passed
@anton-vlasenko anton-vlasenko deleted the fix/address-nitpicks-in-font-library-unit-tests-round-2 branch February 2, 2024 13:05
@github-actions github-actions bot added this to the Gutenberg 17.7 milestone Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Font Library [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants