Skip to content

Commit 65b198c

Browse files
committed
Update covers tags and use HTML Tag Processor
1 parent 1fd3a4d commit 65b198c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

plugins/webp-uploads/tests/test-load.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,8 +1271,6 @@ static function () {
12711271

12721272
/**
12731273
* Test that the webp_uploads_update_featured_image function is hooked to the post_thumbnail_html filter.
1274-
*
1275-
* @covers ::webp_uploads_update_featured_image
12761274
*/
12771275
public function test_webp_uploads_update_featured_image_hooked_into_post_thumbnail_html(): void {
12781276
$this->assertSame( 10, has_filter( 'post_thumbnail_html', 'webp_uploads_update_featured_image' ) );
@@ -1282,6 +1280,7 @@ public function test_webp_uploads_update_featured_image_hooked_into_post_thumbna
12821280
* Test that the featured image is not wrapped in a picture element.
12831281
*
12841282
* @covers ::webp_uploads_update_featured_image
1283+
* @covers ::webp_uploads_img_tag_update_mime_type
12851284
*/
12861285
public function test_webp_uploads_update_featured_image_picture_element_disabled(): void {
12871286
$attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' );
@@ -1296,6 +1295,7 @@ public function test_webp_uploads_update_featured_image_picture_element_disabled
12961295
* Test that the featured image is wrapped in a picture element.
12971296
*
12981297
* @covers ::webp_uploads_update_featured_image
1298+
* @covers ::webp_uploads_wrap_image_in_picture
12991299
*/
13001300
public function test_webp_uploads_update_featured_image_picture_element_enabled(): void {
13011301
update_option( 'perflab_generate_webp_and_jpeg', '1' );

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,8 @@ public function test_wrap_image_in_picture_with_false_image_src(): void {
534534
*
535535
* @param string $context The context to test.
536536
* @param bool $expected Whether the image should be wrapped in a picture element.
537+
*
538+
* @covers ::webp_uploads_wrap_image_in_picture
537539
*/
538540
public function test_webp_uploads_wrap_image_in_picture_with_different_context( string $context, bool $expected ): void {
539541
$image = wp_get_attachment_image(
@@ -549,7 +551,13 @@ public function test_webp_uploads_wrap_image_in_picture_with_different_context(
549551
$this->opt_in_to_picture_element();
550552
$filtered_image = apply_filters( 'wp_content_img_tag', $image, $context, self::$image_id );
551553
if ( $expected ) {
552-
$this->assertStringStartsWith( '<picture', $filtered_image );
554+
$processor = new WP_HTML_Tag_Processor( $filtered_image );
555+
$this->assertTrue( $processor->next_tag() );
556+
$this->assertSame( 'PICTURE', $processor->get_tag() );
557+
$this->assertTrue( $processor->next_tag() );
558+
$this->assertSame( 'SOURCE', $processor->get_tag() );
559+
$this->assertTrue( $processor->next_tag() );
560+
$this->assertSame( 'IMG', $processor->get_tag() );
553561
} else {
554562
$this->assertSame( $image, $filtered_image );
555563
}

0 commit comments

Comments
 (0)