Skip to content

Commit 0ed443b

Browse files
Unit test for three column layout
1 parent 47df817 commit 0ed443b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,34 @@ public function test_image_block_in_two_column_layout_renders_correct_sizes_attr
12971297
$this->assertStringContainsString( 'sizes="(max-width: 310px) 100vw, 310px" ', $result );
12981298
}
12991299

1300+
/**
1301+
* Test that the image block in a three-column layout renders the correct sizes attribute.
1302+
*/
1303+
public function test_image_block_in_three_column_layout_renders_correct_sizes_attribute(): void {
1304+
// Skip test for WordPress versions below 6.8.
1305+
if ( version_compare( get_bloginfo( 'version' ), '6.8', '<' ) ) {
1306+
$this->markTestSkipped( 'This test requires WordPress 6.8 or higher.' );
1307+
}
1308+
1309+
$block_content = '<!-- wp:columns -->
1310+
<div class="wp-block-columns"><!-- wp:column -->
1311+
<div class="wp-block-column">
1312+
' . $this->get_image_block_markup( self::$image_id, 'large' ) . '
1313+
</div>
1314+
<!-- /wp:column -->
1315+
<!-- wp:column -->
1316+
<div class="wp-block-column"></div>
1317+
<!-- /wp:column -->
1318+
<!-- wp:column -->
1319+
<div class="wp-block-column"></div>
1320+
<!-- /wp:column --></div>
1321+
<!-- /wp:columns -->';
1322+
1323+
$result = apply_filters( 'the_content', $block_content );
1324+
1325+
$this->assertStringContainsString( 'sizes="(max-width: 206px) 100vw, 206px" ', $result );
1326+
}
1327+
13001328
/**
13011329
* Verifies that the post featured image block does not render when no featured image is set for the post.
13021330
*/

0 commit comments

Comments
 (0)