@@ -21,12 +21,13 @@ class Dynamic_Blocks_Render_Test extends WP_UnitTestCase {
21
21
* Dummy block rendering function.
22
22
*
23
23
* @param array $attributes Block attributes.
24
+ * @param array $content Content.
24
25
*
25
26
* @return string Block output.
26
27
*/
27
- function render_dummy_block ( $ attributes ) {
28
+ function render_dummy_block ( $ attributes, $ content ) {
28
29
$ this ->dummy_block_instance_number += 1 ;
29
- return $ this ->dummy_block_instance_number . ': ' . $ attributes ['value ' ];
30
+ return $ this ->dummy_block_instance_number . ': ' . $ attributes ['value ' ] . " : $ content " ;
30
31
}
31
32
32
33
/**
@@ -64,11 +65,11 @@ function test_dynamic_block_rendering() {
64
65
$ updated_post_content = do_blocks ( $ post_content );
65
66
$ this ->assertEquals ( $ updated_post_content ,
66
67
'before ' .
67
- '1:b1 ' .
68
- '2:b1 ' .
68
+ '1:b1: ' .
69
+ '2:b1: ' .
69
70
'between ' .
70
- '3:b2 ' .
71
- '4:b2 ' .
71
+ '3:b2: ' .
72
+ '4:b2: ' .
72
73
'after '
73
74
);
74
75
}
@@ -88,17 +89,17 @@ function test_dynamic_block_rendering_with_content() {
88
89
register_block_type ( 'core/dummy ' , $ settings );
89
90
$ post_content =
90
91
'before ' .
91
- '<!-- wp:core/dummy value="b1" -->this should be ignored <!-- /wp:core/dummy --> ' .
92
+ '<!-- wp:core/dummy value="b1" -->content1 <!-- /wp:core/dummy --> ' .
92
93
'between ' .
93
- '<!-- wp:core/dummy value="b2" -->this should also be ignored <!-- /wp:core/dummy --> ' .
94
+ '<!-- wp:core/dummy value="b2" -->content2 <!-- /wp:core/dummy --> ' .
94
95
'after ' ;
95
96
96
97
$ updated_post_content = do_blocks ( $ post_content );
97
98
$ this ->assertEquals ( $ updated_post_content ,
98
99
'before ' .
99
- '1:b1 ' .
100
+ '1:b1:content1 ' .
100
101
'between ' .
101
- '2:b2 ' .
102
+ '2:b2:content2 ' .
102
103
'after '
103
104
);
104
105
}
0 commit comments