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

Block Bindings API: Add tests and fix newly discovered edge cases #57899

Closed
wants to merge 3 commits into from

Conversation

artemiomorales
Copy link
Contributor

@artemiomorales artemiomorales commented Jan 16, 2024

What?

This PR adds tests for the Block Bindings API, first introduced in #57249 and refactored in #57742. It also fixes bugs that were discovered as a result of writing the tests.

Why?

In order to merge this functionality for WP 6.5, we need tests to ensure code quality into the future.

Testing Instructions

  • Run the tests locally using PHP Unit.
  • Please check to see what other test cases we can add.

@artemiomorales artemiomorales added [Feature] Block API API that allows to express the block paradigm. [Type] New API New API to be used by plugin developers or package users. [Feature] Custom Fields Anything related to the custom fields project - connecting block attributes and dynamic values labels Jan 16, 2024
Copy link

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/experimental/WP_Block_Bindings_Test.php
❔ lib/experimental/block-bindings/class-wp-block-bindings.php

Copy link
Contributor Author

@artemiomorales artemiomorales left a comment

Choose a reason for hiding this comment

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

Questions for reviewers regarding this first pass on the tests:

  • I was unable to get these tests to run locally without making the name of the test file match the name of the test class. Should we just rename the file to follow the convention of the rest of the tests?
  • I needed to include the Block Bindings code with set_up_before_class when running the tests because it's currently locked behind an experiment. Should we leave this in for now?
  • How do these tests look? Are there any cases we should add or modify?

@artemiomorales artemiomorales marked this pull request as ready for review January 16, 2024 23:58
@artemiomorales artemiomorales changed the title Add tests; fix bug wherein block content was erased Block Bindings API: Add tests and fix newly discovered edge cases Jan 16, 2024
Base automatically changed from update/improve-block-bindings-api to trunk January 17, 2024 12:22
@michalczaplinski
Copy link
Contributor

michalczaplinski commented Jan 23, 2024

@artemiomorales I think that we can close this one as the tests will live in Core: WordPress/wordpress-develop#5888

The bugfix is also present in the PR to Core.

@artemiomorales
Copy link
Contributor Author

@artemiomorales I think that we can close this one as the tests will live in Core: WordPress/wordpress-develop#5888

The bugfix is also present in the PR to Core.

Ok sounds good — we can backport to Gutenberg once the core PR lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Custom Fields Anything related to the custom fields project - connecting block attributes and dynamic values [Type] New API New API to be used by plugin developers or package users.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants