Skip to content

Commit

Permalink
Unregister sources in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed Jul 22, 2024
1 parent 2b2bed5 commit a18de61
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/phpunit/tests/block-bindings/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public function test_get_all_registered() {
);

$registered = get_all_registered_block_bindings_sources();
unregister_block_bindings_source( 'test/source-one' );
unregister_block_bindings_source( 'test/source-two' );
unregister_block_bindings_source( 'test/source-three' );
$this->assertEquals( $expected, $registered );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ public function test_get_all_registered() {
);

$registered = $this->registry->get_all_registered();
$this->registry->unregister( 'test/source-one' );
$this->registry->unregister( 'test/source-two' );
$this->registry->unregister( 'test/source-three' );
$this->assertEquals( $expected, $registered );
}

Expand Down Expand Up @@ -311,6 +314,9 @@ public function test_get_registered() {

$expected = new WP_Block_Bindings_Source( $source_two_name, $source_two_properties );
$result = $this->registry->get_registered( 'test/source-two' );
$this->registry->unregister( 'test/source-one' );
$this->registry->unregister( 'test/source-two' );
$this->registry->unregister( 'test/source-three' );

$this->assertEquals(
$expected,
Expand Down Expand Up @@ -380,6 +386,8 @@ public function test_merging_uses_context_from_multiple_sources() {
);

$new_uses_context = $block_registry->get_registered( 'core/paragraph' )->uses_context;
unregister_block_bindings_source( 'test/source-one' );
unregister_block_bindings_source( 'test/source-two' );
// Checks that the resulting `uses_context` contains the values from both sources.
$this->assertContains( 'commonContext', $new_uses_context );
$this->assertContains( 'sourceOneContext', $new_uses_context );
Expand Down
2 changes: 2 additions & 0 deletions tests/phpunit/tests/blocks/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,8 @@ public function test_get_block_editor_settings_block_bindings_sources() {
);
$settings = get_block_editor_settings( array(), $block_editor_context );
$exposed_sources = $settings['blockBindingsSources'];
unregister_block_bindings_source( 'test/source-one' );
unregister_block_bindings_source( 'test/source-two' );
// It is expected to have 4 sources: the 2 registered sources in the test, and the 2 core sources.
$this->assertCount( 4, $exposed_sources );
$source_one = $exposed_sources['test/source-one'];
Expand Down

0 comments on commit a18de61

Please sign in to comment.