Skip to content

Commit da82760

Browse files
committed
Refactor test case to remove custom image sizes parameter and simplify data provider
1 parent f544101 commit da82760

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

plugins/webp-uploads/tests/test-picture-element.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -302,20 +302,13 @@ function ( string $content ): string {
302302
* @dataProvider data_provider_test_picture_element_source_tag_srcset_has_same_image_sizes_as_img_tag_srcset
303303
* @covers ::webp_uploads_wrap_image_in_picture
304304
*
305-
* @param Closure|null $set_up Set up the test.
306-
* @param array<string>|null $custom_sizes Custom image sizes.
305+
* @param Closure|null $set_up Set up the test.
307306
*/
308-
public function test_picture_element_source_tag_srcset_has_same_image_sizes_as_img_tag_srcset( ?Closure $set_up, ?array $custom_sizes ): void {
307+
public function test_picture_element_source_tag_srcset_has_same_image_sizes_as_img_tag_srcset( ?Closure $set_up ): void {
309308
if ( $set_up instanceof Closure ) {
310309
$set_up();
311310
}
312311

313-
if ( is_array( $custom_sizes ) ) {
314-
foreach ( $custom_sizes as $size ) {
315-
$this->temp_custom_image_sizes[] = $size;
316-
}
317-
}
318-
319312
update_option( 'perflab_generate_webp_and_jpeg', '1' );
320313
update_option( 'perflab_generate_all_fallback_sizes', '1' );
321314

@@ -371,17 +364,17 @@ public function test_picture_element_source_tag_srcset_has_same_image_sizes_as_i
371364
/**
372365
* Data provider for test_picture_element_source_tag_srcset_has_same_image_sizes_as_img_tag_srcset.
373366
*
374-
* @return array<string, array{ set_up: Closure|null, custom_sizes: array<string>|null }>
367+
* @return array<string, array{ set_up: Closure|null }>
375368
*/
376369
public function data_provider_test_picture_element_source_tag_srcset_has_same_image_sizes_as_img_tag_srcset(): array {
377370
return array(
378371
'default_sizes' => array(
379-
'set_up' => null,
380-
'custom_sizes' => null,
372+
'set_up' => null,
381373
),
382374
'when_two_different_image_sizes_have_same_width' => array(
383-
'set_up' => static function (): void {
375+
'set_up' => function (): void {
384376
add_image_size( 'square', 768, 768, true );
377+
$this->temp_custom_image_sizes[] = 'square';
385378
add_filter(
386379
'pre_option_medium_large_size_w',
387380
static function () {
@@ -395,7 +388,6 @@ static function () {
395388
}
396389
);
397390
},
398-
'custom_sizes' => array( 'square' ),
399391
),
400392
);
401393
}

0 commit comments

Comments
 (0)