Skip to content

Conversation

@tellthemachines
Copy link
Contributor

Trac ticket: https://core.trac.wordpress.org/ticket/59358

This PR syncs the changes from WordPress/gutenberg#54485 and adds a test for the Post Content block with empty attributes.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @tellthemachines. One thing looks off to me here as far as I can tell.

switch_theme( 'block-theme-post-content-default' );

$this->assertSame( $attributes_empty, wp_get_post_content_block_attributes() );
}
Copy link
Member

Choose a reason for hiding this comment

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

Related to my above feedback, maybe add another test for get_block_editor_settings(), to check that it doesn't include the postContentAttributes field if the post block attributes aren't set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original test already checks the return value for classic themes (when Post Content doesn't exist), do you think it would be worth splitting that check out into its own test?

Copy link
Member

Choose a reason for hiding this comment

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

@tellthemachines I meant a test for the get_block_editor_settings() change. As far as I can tell, there isn't one at the moment.

There is https://github.com/WordPress/wordpress-develop/blob/trunk/tests/phpunit/tests/blocks/editor.php#L524 which checks the presence of postContentAttributes, so I think we should add another test where we force wp_get_post_content_block_attributes() to return null, and then assert that get_block_editor_settings() does not include the postContentAttributes key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh got it! Yeah that's a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a test in 0e75e53

Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

Thanks @tellthemachines for the PR. Left some nit-pick document and unit test changes.

* Retrieves Post Content block attributes from the current post template.
*
* @since 6.3.0
* @since 6.4.0 return null by default and return empty array when Post Content block exists. but has no attributes.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @since 6.4.0 return null by default and return empty array when Post Content block exists. but has no attributes.
* @since 6.4.0 return null by default or an empty array when the Post Content block exists. but has no attributes.

switch_theme( 'block-theme-post-content-default' );

$this->assertSame( $attributes_empty, wp_get_post_content_block_attributes() );
}
Copy link
Member

Choose a reason for hiding this comment

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

@tellthemachines I meant a test for the get_block_editor_settings() change. As far as I can tell, there isn't one at the moment.

There is https://github.com/WordPress/wordpress-develop/blob/trunk/tests/phpunit/tests/blocks/editor.php#L524 which checks the presence of postContentAttributes, so I think we should add another test where we force wp_get_post_content_block_attributes() to return null, and then assert that get_block_editor_settings() does not include the postContentAttributes key.

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

Thank you for the updates @tellthemachines, LGTM!

@tellthemachines
Copy link
Contributor Author

Thanks for the reviews! Committed in r56629.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants