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

Add unit tests for block_has_support #1280

Closed

Conversation

ntsekouras
Copy link

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

This PR just adds some unit tests for block_has_support function.

What I wanted to verify though is if this is the expected behavior in the case we have declared supports for a key with an empty array. Should this return true as it does now?

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 );
}

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.

tests/phpunit/tests/blocks/block.php Outdated Show resolved Hide resolved
tests/phpunit/tests/blocks/block.php Outdated Show resolved Hide resolved
@gziolo
Copy link
Member

gziolo commented May 22, 2021

What I wanted to verify though is if this is the expected behavior in the case we have declared supports for a key with an empty array. Should this return true as it does now?

You can file an issue to discuss it separately. It's an edge case that you don't see in a real life. I believe it should return false but it's also could be considered wrong input data like providing a number.

@gziolo
Copy link
Member

gziolo commented May 24, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants