WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 3 months ago

Last modified 7 weeks ago

#53257 closed enhancement (fixed)

Function `block_has_support` needs some unit tests

Reported by: ntsekouras Owned by: 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 months ago

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

#2 @prbot
3 months ago

gziolo commented on PR #1280:

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 months 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
7 weeks ago

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