Skip to content

Fix doing it wrong in Free wp tests#22108

Merged
enricobattocchi merged 10 commits intotrunkfrom
fix-doing_it_wrong-in-wp-tests
Sep 26, 2025
Merged

Fix doing it wrong in Free wp tests#22108
enricobattocchi merged 10 commits intotrunkfrom
fix-doing_it_wrong-in-wp-tests

Conversation

@leonidasmi
Copy link
Copy Markdown
Contributor

@leonidasmi leonidasmi commented Mar 17, 2025

Context

  • This is the plan to both silence those notices in WP test but still be informed about any new ones in the future and this PR is a vital step of that.

Summary

This PR can be summarized in the following changelog entry:

  • Prevents noise in WP tests from doing_it_wrong notices due to _load_textdomain_just_in_time being called too early.

Relevant technical choices:

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

Attention: Uninstall Query Monitor and enable DEBUG_LOG to test the below, because query monitor always shows the notices we're trying to hide in WP.

  • Confirm in the WP tests that there's no _load_textdomain_just_in_time notices, like there are without this PR.
  • Test that we silence a _load_textdomain_just_in_time notice only on WP tests:
    • In inc/class-upgrade.php, at finish_up() add WPSEO_Options::get( 'disable-attachment' ); in the first line.
    • Do a upgrade using the test helper and confirm that you get a couple of Notice: Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. in your debug.log file.
  • Test that we don't silence other doing_it_wrong notices on WP tests:
    • In src\helpers\current-page-helper.php, at the get_term_id() function, add the following in the first line:
   _doing_it_wrong(
       'example_function',
       __( 'Example text.', 'doing_it_wrong_plugin' ),
       '1.0.0'
   );
  • Run the Current_Page_Helper_Test WP test locally and confirm that you get errors

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.
  • Test that we silence a _load_textdomain_just_in_time notice only on WP tests:
    • In inc/class-upgrade.php, at finish_up() add WPSEO_Options::get( 'disable-attachment' ); in the first line.
    • Do a upgrade using the test helper and confirm that you get a couple of Notice: Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. in your debug.log file.

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes #

@leonidasmi leonidasmi added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Mar 17, 2025
@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 32824994fe61c53fa97908a4cbabee2973c9233d

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 10 (0.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on fix-doing_it_wrong-in-wp-tests at 49.501%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/conditionals/wp-tests-conditional.php 0 2 0.0%
src/initializers/silence-load-textdomain-just-in-time-notices.php 0 8 0.0%
Totals Coverage Status
Change from base Build 08180d46952c853b29fb1232f6ce6805f2658220: 49.5%
Covered Lines: 17312
Relevant Lines: 34973

💛 - Coveralls

@leonidasmi leonidasmi marked this pull request as ready for review September 26, 2025 06:52
@leonidasmi leonidasmi changed the title Fix doing it wrong in wp tests Fix doing it wrong in Free wp tests Sep 26, 2025
Copy link
Copy Markdown
Member

@enricobattocchi enricobattocchi left a comment

Choose a reason for hiding this comment

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

CR & ACC ok

@enricobattocchi enricobattocchi added this to the 26.2 milestone Sep 26, 2025
@enricobattocchi enricobattocchi merged commit 46120a2 into trunk Sep 26, 2025
23 of 28 checks passed
@enricobattocchi enricobattocchi deleted the fix-doing_it_wrong-in-wp-tests branch September 26, 2025 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants