- Timestamp:
- 09/23/2024 12:33:14 PM (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php
r58799 r59080 345 345 $this->assertTrue( $result ); 346 346 } 347 348 /**349 * Tests merging `uses_context` from multiple sources.350 *351 * @ticket 60525352 *353 * @covers ::register_block_bindings_source354 * @covers WP_Block_Type::get_uses_context355 */356 public function test_merging_uses_context_from_multiple_sources() {357 $get_value_callback = function () {358 return 'Anything';359 };360 361 $block_registry = WP_Block_Type_Registry::get_instance();362 $original_uses_context = $block_registry->get_registered( 'core/paragraph' )->uses_context;363 364 register_block_bindings_source(365 'test/source-one',366 array(367 'label' => 'Test Source One',368 'get_value_callback' => $get_value_callback,369 'uses_context' => array( 'commonContext', 'sourceOneContext' ),370 )371 );372 373 register_block_bindings_source(374 'test/source-two',375 array(376 'label' => 'Test Source Two',377 'get_value_callback' => $get_value_callback,378 'uses_context' => array( 'commonContext', 'sourceTwoContext' ),379 )380 );381 382 $new_uses_context = $block_registry->get_registered( 'core/paragraph' )->uses_context;383 unregister_block_bindings_source( 'test/source-one' );384 unregister_block_bindings_source( 'test/source-two' );385 // Checks that the resulting `uses_context` contains the values from both sources.386 $this->assertContains( 'commonContext', $new_uses_context );387 $this->assertContains( 'sourceOneContext', $new_uses_context );388 $this->assertContains( 'sourceTwoContext', $new_uses_context );389 // Checks that the resulting `uses_context` added 3 unique items.390 $this->assertSame( count( $original_uses_context ) + 3, count( $new_uses_context ) );391 // Checks that the array isn't sparse to prevent issues in the editor.392 $this->assertSame( array_key_last( $new_uses_context ), count( $new_uses_context ) - 1 );393 }394 347 }
Note: See TracChangeset
for help on using the changeset viewer.