Skip to content

Commit b15d7fe

Browse files
Sarthak JaiswalSarthak Jaiswal
authored andcommitted
Add code test coverage for a continue statement
1 parent 8efea15 commit b15d7fe

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

plugins/auto-sizes/includes/improve-calculate-sizes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function auto_sizes_prime_attachment_caches( $content ): string {
2626
$class = $processor->get_attribute( 'class' );
2727

2828
if ( ! is_string( $class ) ) {
29-
continue; // @codeCoverageIgnore
29+
continue;
3030
}
3131

3232
if ( preg_match( '/(?:^|\s)wp-image-([1-9][0-9]*)(?:\s|$)/', $class, $class_id ) === 1 ) {

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,4 +714,18 @@ public function get_group_block_markup( string $content, array $atts = array() )
714714
<div class="wp-block-group' . $align_class . '">' . $content . '</div>
715715
<!-- /wp:group -->';
716716
}
717+
718+
/**
719+
* Tests the auto_sizes_prime_attachment_caches function.
720+
*
721+
* @covers ::auto_sizes_prime_attachment_caches
722+
*/
723+
public function test_auto_sizes_prime_attachment_caches_with_empty_class(): void {
724+
$img_tag = '<img src="https://example.com/foo.png">';
725+
726+
$result = auto_sizes_prime_attachment_caches( $img_tag );
727+
728+
// Assert that the output is the same as the input since no processing should occur.
729+
$this->assertSame( $img_tag, $result );
730+
}
717731
}

0 commit comments

Comments
 (0)