@@ -1272,6 +1272,63 @@ public static function data_image_block_with_parent_columns_and_its_parent_group
1272
1272
);
1273
1273
}
1274
1274
1275
+ /**
1276
+ * Test that the image block in a two-column layout renders the correct sizes attribute.
1277
+ *
1278
+ * @cover ::auto_sizes_filter_image_tag
1279
+ */
1280
+ public function test_image_block_in_two_column_layout_renders_correct_sizes_attribute (): void {
1281
+ // Skip test for WordPress versions below 6.8.
1282
+ if ( version_compare ( get_bloginfo ( 'version ' ), '6.8 ' , '< ' ) ) {
1283
+ $ this ->markTestSkipped ( 'This test requires WordPress 6.8 or higher. ' );
1284
+ }
1285
+
1286
+ $ block_content = '<!-- wp:columns -->
1287
+ <div class="wp-block-columns"><!-- wp:column -->
1288
+ <div class="wp-block-column">
1289
+ ' . $ this ->get_image_block_markup ( self ::$ image_id , 'large ' ) . '
1290
+ </div>
1291
+ <!-- /wp:column -->
1292
+ <!-- wp:column -->
1293
+ <div class="wp-block-column"></div>
1294
+ <!-- /wp:column --></div>
1295
+ <!-- /wp:columns --> ' ;
1296
+
1297
+ $ result = apply_filters ( 'the_content ' , $ block_content );
1298
+
1299
+ $ this ->assertStringContainsString ( 'sizes="(max-width: 310px) 100vw, 310px" ' , $ result );
1300
+ }
1301
+
1302
+ /**
1303
+ * Test that the image block in a three-column layout renders the correct sizes attribute.
1304
+ *
1305
+ * @cover ::auto_sizes_filter_image_tag
1306
+ */
1307
+ public function test_image_block_in_three_column_layout_renders_correct_sizes_attribute (): void {
1308
+ // Skip test for WordPress versions below 6.8.
1309
+ if ( version_compare ( get_bloginfo ( 'version ' ), '6.8 ' , '< ' ) ) {
1310
+ $ this ->markTestSkipped ( 'This test requires WordPress 6.8 or higher. ' );
1311
+ }
1312
+
1313
+ $ block_content = '<!-- wp:columns -->
1314
+ <div class="wp-block-columns"><!-- wp:column -->
1315
+ <div class="wp-block-column">
1316
+ ' . $ this ->get_image_block_markup ( self ::$ image_id , 'large ' ) . '
1317
+ </div>
1318
+ <!-- /wp:column -->
1319
+ <!-- wp:column -->
1320
+ <div class="wp-block-column"></div>
1321
+ <!-- /wp:column -->
1322
+ <!-- wp:column -->
1323
+ <div class="wp-block-column"></div>
1324
+ <!-- /wp:column --></div>
1325
+ <!-- /wp:columns --> ' ;
1326
+
1327
+ $ result = apply_filters ( 'the_content ' , $ block_content );
1328
+
1329
+ $ this ->assertStringContainsString ( 'sizes="(max-width: 206px) 100vw, 206px" ' , $ result );
1330
+ }
1331
+
1275
1332
/**
1276
1333
* Verifies that the post featured image block does not render when no featured image is set for the post.
1277
1334
*/
0 commit comments