Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#53257 closed enhancement (fixed)

Function `block_has_support` needs some unit tests

Reported by: ntsekouras's profile ntsekouras Owned by: gziolo's profile gziolo
Milestone: 5.8 Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

Function block_has_support needs some unit tests

Change History (5)

This ticket was mentioned in PR #1280 on WordPress/wordpress-develop by ntsekouras.


3 years ago
#1

  • Keywords has-patch has-unit-tests added

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

gziolo commented on PR #1280:


3 years ago
#2

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.

#3 @gziolo
3 years ago

  • Owner set to gziolo
  • Resolution set to fixed
  • Status changed from new to closed

In 50955:

Editor: Add missing unit tests for block_has_support

Follow-up for [50761].
Props ntsekouras.
Fixes #53257. See #52991.

#5 @desrosj
3 years ago

  • Milestone changed from Awaiting Review to 5.8
Note: See TracTickets for help on using tickets.