'My Block Binding', 'get_value_callback' => function ( $source_args, $block ) { return $block->context['my-custom/context'] ?? 'Fallback value provided by block bindings source'; }, 'uses_context' => array( 'my-custom/context' ), ) ); self::$block_id = $factory->post->create( array( 'post_type' => 'wp_block', 'post_status' => 'publish', 'post_title' => 'Test Block', 'post_content' => '

Hello world!

', ) ); } public static function wpTearDownAfterClass() { wp_delete_post( self::$block_id, true ); unregister_block_bindings_source( 'test/block-binding' ); } /** * @see https://github.com/WordPress/gutenberg/issues/70391 */ public function test_render_respects_custom_context() { $synced_pattern_block_instance = new WP_Block( array( 'blockName' => 'core/block', 'attrs' => array( 'ref' => self::$block_id, ), ), array( 'my-custom/context' => 'Custom content set from block context', ) ); $output = $synced_pattern_block_instance->render(); $this->assertSame( '

Custom content set from block context

', $output ); } }