Skip to content

Commit

Permalink
Adapt test to check only expected properties
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed Jul 22, 2024
1 parent 745509a commit ac767be
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions tests/phpunit/tests/blocks/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -730,11 +730,22 @@ public function test_get_block_editor_settings_block_bindings_sources() {
$registered_block_bindings_sources = get_all_registered_block_bindings_sources();

foreach ( $registered_block_bindings_sources as $name => $properties ) {
$registered_properties = get_object_vars( $properties );
// Remove name property as it is not part of the settings.
unset( $registered_properties['name'] );
$settings_properties = $settings['blockBindingsSources'][ $name ];
$this->assertSameSets( $registered_properties, $settings_properties );
// Check all the registered sources are exposed.
$this->assertArrayHasKey( $name, $settings['blockBindingsSources'] );

// Check only the expected properties are included, and they have the proper value.
$expected_properties = array(
'label' => $properties->label,
);
// Add optional properties if they are defined.
if ( ! empty( $properties->uses_context ) ) {
$expected_properties['usesContext'] = $properties->uses_context;
}

$this->assertSameSets(
$expected_properties,
$settings['blockBindingsSources'][ $name ]
);
}
}
}

0 comments on commit ac767be

Please sign in to comment.