Make WordPress Core


Ignore:
Timestamp:
05/05/2021 05:06:17 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Media: Some documentation and test improvements for WebP support:

  • Document that WebP constants are only defined in PHP 7.1+.
  • Correct the $filename parameter type in wp_get_webp_info().
  • Use a consistent message when skipping tests due to the lack of WebP support.
  • Remove unnecessary else branches after markTestSkipped().
  • Replace assertEquals() with more appropriate assertions.

Follow-up to [50810].

See #35725.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/image/resize.php

    r50810 r50814  
    7171        // Check if the editor supports the webp mime type.
    7272        if ( is_wp_error( $editor ) || ! $editor->supports_mime_type( 'image/webp' ) ) {
    73             $this->markTestSkipped( sprintf( 'Skipping test: no WebP support in the editor engine %s on this system.', $this->editor_engine ) );
    74         } else {
    75             $image = $this->resize_helper( $file, 25, 25 );
    76             $this->assertSame( 'test-image-25x25.webp', wp_basename( $image ) );
    77             list($w, $h, $type) = wp_getimagesize( $image );
    78             $this->assertSame( 25, $w );
    79             $this->assertSame( 25, $h );
    80             $this->assertSame( IMAGETYPE_WEBP, $type );
    81             unlink( $image );
    82         }
     73            $this->markTestSkipped( sprintf( 'No WebP support in the editor engine %s on this system.', $this->editor_engine ) );
     74        }
     75
     76        $image = $this->resize_helper( $file, 25, 25 );
     77        $this->assertSame( 'test-image-25x25.webp', wp_basename( $image ) );
     78        list($w, $h, $type) = wp_getimagesize( $image );
     79        $this->assertSame( 25, $w );
     80        $this->assertSame( 25, $h );
     81        $this->assertSame( IMAGETYPE_WEBP, $type );
     82        unlink( $image );
    8383    }
    8484
Note: See TracChangeset for help on using the changeset viewer.