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

Query block enhanced pagination: Simplify test setup #55805

Merged
merged 1 commit into from Nov 2, 2023

Conversation

DAreRodz
Copy link
Contributor

@DAreRodz DAreRodz commented Nov 2, 2023

What?

Follow-up of #55714.

This PR improves how the Query block tests for the enhanced pagination are initialized.

Why?

To make tests a little bit more performant and straightforward.

How?

Using wpSetUpBeforeClass() and $factory->post->create_many() as suggested in this discussion.

Testing Instructions

N/A

@DAreRodz DAreRodz added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Block] Query Loop Affects the Query Loop Block labels Nov 2, 2023
@DAreRodz DAreRodz self-assigned this Nov 2, 2023
Copy link

github-actions bot commented Nov 2, 2023

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/blocks/render-query-test.php

@gziolo
Copy link
Member

gziolo commented Nov 2, 2023

I wasn't aware that you could use wpSetUpBeforeClass and wpTearDownAfterClass. It's covered in the docs at https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#slow-fixtures.

It is an abstraction integrated with set_up_before_class and tear_down_after_class which I usually see used instead.

Thank you for working on this enhancement!

Copy link

github-actions bot commented Nov 2, 2023

Flaky tests detected in 48732cb.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6732737583
📝 Reported issues:

@DAreRodz DAreRodz merged commit 6266974 into trunk Nov 2, 2023
55 checks passed
@DAreRodz DAreRodz deleted the update/query-block-enhanced-pagination-tests branch November 2, 2023 13:49
@github-actions github-actions bot added this to the Gutenberg 17.1 milestone Nov 2, 2023
@getdave
Copy link
Contributor

getdave commented Jan 25, 2024

Reviewing this one it appears the test files are within phpunit/blocks which don't require backporting to WP Core.

✅ I updated the PHP Sync Tracking Issue for WP 6.5 to note this PR does not require a backport for WP 6.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Query Loop Affects the Query Loop Block [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants