#53257 closed enhancement (fixed)
Function `block_has_support` needs some unit tests
| Reported by: | ntsekouras | Owned by: | gziolo |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.8 |
| Component: | Editor | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
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.
5 years ago
#1
- Keywords has-patch has-unit-tests added
5 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.
5 years ago
#4
Committed in https://core.trac.wordpress.org/changeset/50955.
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Trac ticket: https://core.trac.wordpress.org/ticket/53257
This PR just adds some unit tests for
block_has_supportfunction.What I wanted to verify though is if this is the expected behavior in the case we have declared
supportsfor a key with anempty 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 ); }