Skip to content

Commit 47df817

Browse files
Unit test for two column layout
1 parent 123450c commit 47df817

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

plugins/auto-sizes/tests/test-improve-calculate-sizes.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,31 @@ public static function data_image_block_with_parent_columns_and_its_parent_group
12721272
);
12731273
}
12741274

1275+
/**
1276+
* Test that the image block in a two-column layout renders the correct sizes attribute.
1277+
*/
1278+
public function test_image_block_in_two_column_layout_renders_correct_sizes_attribute(): void {
1279+
// Skip test for WordPress versions below 6.8.
1280+
if ( version_compare( get_bloginfo( 'version' ), '6.8', '<' ) ) {
1281+
$this->markTestSkipped( 'This test requires WordPress 6.8 or higher.' );
1282+
}
1283+
1284+
$block_content = '<!-- wp:columns -->
1285+
<div class="wp-block-columns"><!-- wp:column -->
1286+
<div class="wp-block-column">
1287+
' . $this->get_image_block_markup( self::$image_id, 'large' ) . '
1288+
</div>
1289+
<!-- /wp:column -->
1290+
<!-- wp:column -->
1291+
<div class="wp-block-column"></div>
1292+
<!-- /wp:column --></div>
1293+
<!-- /wp:columns -->';
1294+
1295+
$result = apply_filters( 'the_content', $block_content );
1296+
1297+
$this->assertStringContainsString( 'sizes="(max-width: 310px) 100vw, 310px" ', $result );
1298+
}
1299+
12751300
/**
12761301
* Verifies that the post featured image block does not render when no featured image is set for the post.
12771302
*/

0 commit comments

Comments
 (0)