Skip to content

Commit 30a494c

Browse files
committed
Use Reflection to make tests work again
1 parent 716037a commit 30a494c

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,23 @@
1010
* @group block-bindings
1111
*/
1212
class Tests_Blocks_wpBlockBindingsProcessor extends WP_UnitTestCase {
13+
14+
private static $get_block_bindings_processor_method;
15+
16+
public static function wpSetupBeforeClass() {
17+
self::$get_block_bindings_processor_method = new ReflectionMethod( 'WP_Block', 'get_block_bindings_processor' );
18+
self::$get_block_bindings_processor_method->setAccessible( true );
19+
}
20+
1321
/**
1422
* @ticket 63840
1523
*/
1624
public function test_replace_rich_text() {
1725
$button_wrapper_opener = '<div class="wp-block-button"><a class="wp-block-button__link wp-element-button">';
1826
$button_wrapper_closer = '</a></div>';
19-
$processor = WP_Block_Bindings_Processor::create_fragment(
27+
28+
$processor = self::$get_block_bindings_processor_method->invoke(
29+
null,
2030
$button_wrapper_opener . 'This should not appear' . $button_wrapper_closer
2131
);
2232
$processor->next_tag( array( 'tag_name' => 'a' ) );
@@ -35,7 +45,8 @@ public function test_set_attribute_and_replace_rich_text() {
3545
$figure_opener = '<figure class="wp-block-image">';
3646
$img = '<img src="breakfast.jpg" alt="" class="wp-image-1"/>';
3747
$figure_closer = '</figure>';
38-
$processor = WP_Block_Bindings_Processor::create_fragment(
48+
$processor = self::$get_block_bindings_processor_method->invoke(
49+
null,
3950
$figure_opener .
4051
$img .
4152
'<figcaption class="wp-element-caption">Breakfast at a <em>café</em> in Berlin</figcaption>' .
@@ -64,7 +75,8 @@ public function test_replace_rich_text_and_seek() {
6475
$figure_opener = '<figure class="wp-block-image">';
6576
$img = '<img src="breakfast.jpg" alt="" class="wp-image-1"/>';
6677
$figure_closer = '</figure>';
67-
$processor = WP_Block_Bindings_Processor::create_fragment(
78+
$processor = self::$get_block_bindings_processor_method->invoke(
79+
null,
6880
$figure_opener .
6981
$img .
7082
'<figcaption class="wp-element-caption">Breakfast at a <em>café</em> in Berlin</figcaption>' .

0 commit comments

Comments
 (0)