Skip to content

Commit e6d9c31

Browse files
committed
Add tests and other general doc updates
1 parent 11c72a7 commit e6d9c31

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/wp-includes/class-wp-block.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ public function __get( $name ) {
237237
*
238238
* @since 6.5.0
239239
* @since 6.6.0 Handle the `__default` attribute for pattern overrides.
240+
* @since 6.7.0 Return any updated bindings metadata in the computed attributes.
240241
*
241242
* @return array The computed block attributes for the provided block bindings.
242243
*/
@@ -310,8 +311,8 @@ private function process_block_bindings() {
310311
}
311312
}
312313

313-
// Update the bindings in the computed attributes.
314-
// This ensures the block receives the expanded __default binding when it renders.
314+
// Update the bindings metadata in the computed attributes.
315+
// This ensures the block receives the expanded __default binding metadata when it renders.
315316
$computed_attributes['metadata'] = array_merge(
316317
$parsed_block['attrs']['metadata'],
317318
array( 'bindings' => $bindings )

tests/phpunit/tests/block-bindings/render.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,31 +272,41 @@ public function test_using_symbols_in_block_bindings_value() {
272272
}
273273

274274
/**
275-
* Tests if the `__default` attribute is replaced with real attribues for
275+
* Tests if the `__default` attribute is replaced with real attributes for
276276
* pattern overrides.
277277
*
278278
* @ticket 61333
279+
* @ticket 62069
279280
*
280281
* @covers WP_Block::process_block_bindings
281282
*/
282283
public function test_default_binding_for_pattern_overrides() {
283-
$expected_content = 'This is the content value';
284-
285284
$block_content = <<<HTML
286285
<!-- wp:paragraph {"metadata":{"bindings":{"__default":{"source":"core/pattern-overrides"}},"name":"Test"}} -->
287286
<p>This should not appear</p>
288287
<!-- /wp:paragraph -->
289288
HTML;
290289

291-
$parsed_blocks = parse_blocks( $block_content );
292-
$block = new WP_Block( $parsed_blocks[0], array( 'pattern/overrides' => array( 'Test' => array( 'content' => $expected_content ) ) ) );
293-
$result = $block->render();
290+
$expected_content = 'This is the content value';
291+
$parsed_blocks = parse_blocks( $block_content );
292+
$block = new WP_Block( $parsed_blocks[0], array( 'pattern/overrides' => array( 'Test' => array( 'content' => $expected_content ) ) ) );
293+
294+
$result = $block->render();
294295

295296
$this->assertSame(
296297
"<p>$expected_content</p>",
297298
trim( $result ),
298299
'The `__default` attribute should be replaced with the real attribute prior to the callback.'
299300
);
301+
302+
$expected_bindings_metadata = array(
303+
'content' => array( 'source' => 'core/pattern-overrides' ),
304+
);
305+
$this->assertSame(
306+
$expected_bindings_metadata,
307+
$block->attributes['metadata']['bindings'],
308+
'The __default binding should be updated with the individual binding attributes in the block metadata.'
309+
);
300310
}
301311

302312
/**

0 commit comments

Comments
 (0)