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

[Discussion]: gutenberg_block_has_support validations #32146

Open
ntsekouras opened this issue May 24, 2021 · 0 comments
Open

[Discussion]: gutenberg_block_has_support validations #32146

ntsekouras opened this issue May 24, 2021 · 0 comments
Labels
[Type] Discussion For issues that are high-level and not yet ready to implement.

Comments

@ntsekouras
Copy link
Contributor

While adding some unit tests for gutenberg_block_has_support in core here: WordPress/wordpress-develop#1280, I found it pretty weird that we just check if the value of a supports flag can return true even if as an empty array here: https://github.com/WordPress/gutenberg/blob/trunk/lib/blocks.php#L413

Should this return true as it does now? Should we add some more basic validations?

Example test that passes with an empty array:

public function test_block_has_support_empty_array() {
	$this->registry->register(
		'core/example',
		array(
			'supports' => array(
				'align' => array(),
			),
		)
	);
	$block_type = $this->registry->get_registered( 'core/example' );
	$align_support = block_has_support( $block_type, array( 'align' ) );
	$this->assertSame( $align_support, true );
}
@ntsekouras ntsekouras added the [Type] Discussion For issues that are high-level and not yet ready to implement. label May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Discussion For issues that are high-level and not yet ready to implement.
Projects
None yet
Development

No branches or pull requests

1 participant