Skip to content

Commit c4b7eb7

Browse files
committed
Fix reusable block failures
1 parent bdd571c commit c4b7eb7

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

tests/phpunit/tests/blocks/renderReusable.php

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ public static function wpTearDownAfterClass() {
7777
}
7878

7979
public function test_render() {
80-
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/block' );
81-
$output = $block_type->render( array( 'ref' => self::$block_id ) );
80+
$parsed_block = array(
81+
'blockName' => 'core/block',
82+
'attrs' => array( 'ref' => self::$block_id ),
83+
);
84+
$block = new WP_Block( $parsed_block );
85+
$output = $block->render();
8286
$this->assertSame( '<p>Hello world!</p>', $output );
8387
}
8488

@@ -88,21 +92,33 @@ public function test_render() {
8892
* @ticket 52364
8993
*/
9094
public function test_render_subsequent() {
91-
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/block' );
92-
$output = $block_type->render( array( 'ref' => self::$block_id ) );
93-
$output .= $block_type->render( array( 'ref' => self::$block_id ) );
95+
$parsed_block = array(
96+
'blockName' => 'core/block',
97+
'attrs' => array( 'ref' => self::$block_id ),
98+
);
99+
$block = new WP_Block( $parsed_block );
100+
$output = $block->render();
101+
$output .= $block->render();
94102
$this->assertSame( '<p>Hello world!</p><p>Hello world!</p>', $output );
95103
}
96104

97105
public function test_ref_empty() {
98-
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/block' );
99-
$output = $block_type->render( array() );
106+
$parsed_block = array(
107+
'blockName' => 'core/block',
108+
'attrs' => array(),
109+
);
110+
$block = new WP_Block( $parsed_block );
111+
$output = $block->render();
100112
$this->assertSame( '', $output );
101113
}
102114

103115
public function test_ref_wrong_post_type() {
104-
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/block' );
105-
$output = $block_type->render( array( 'ref' => self::$post_id ) );
116+
$parsed_block = array(
117+
'blockName' => 'core/block',
118+
'attrs' => array( 'ref' => self::$post_id ),
119+
);
120+
$block = new WP_Block( $parsed_block );
121+
$output = $block->render();
106122
$this->assertSame( '', $output );
107123
}
108124
}

0 commit comments

Comments
 (0)