diff --git a/tests/phpunit/tests/blocks/render.php b/tests/phpunit/tests/blocks/render.php index 373217bd74403..9fa48955a894f 100644 --- a/tests/phpunit/tests/blocks/render.php +++ b/tests/phpunit/tests/blocks/render.php @@ -219,12 +219,16 @@ public function test_do_block_output( $html_filename, $server_html_filename ) { } } - $html = do_blocks( self::strip_r( file_get_contents( $html_path ) ) ); - $expected_html = self::strip_r( file_get_contents( $server_html_path ) ); + $html = do_blocks( self::strip_r( file_get_contents( $html_path ) ) ); + // If blocks opt into Gutenberg's layout implementation + // the container will receive an added classname of `wp_unique_id( 'wp-container-' )` + // so we need to normalize the random id. + $normalized_html = preg_replace( '/wp-container-\d+/', 'wp-container-1', $html ); + $expected_html = self::strip_r( file_get_contents( $server_html_path ) ); $this->assertSame( $expected_html, - $html, + $normalized_html, "File '$html_path' does not match expected value" ); }