Make WordPress Core


Ignore:
Timestamp:
05/05/2021 05:06:17 PM (5 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/editor.php

    r50810 r50814  
    206206        public function test_wp_get_webp_info( $file, $expected ) {
    207207                $editor = wp_get_image_editor( $file );
     208
    208209                if ( is_wp_error( $editor ) || ! $editor->supports_mime_type( 'image/webp' ) ) {
    209                         $this->markTestSkipped( sprintf( 'Skipping test: no WebP support in the editor engine %s on this system.', $this->editor_engine ) );
    210                 } else {
    211                         $file_data = wp_get_webp_info( $file );
    212                         $this->assertSame( $file_data, $expected );
     210                        $this->markTestSkipped( sprintf( 'No WebP support in the editor engine %s on this system.', $this->editor_engine ) );
    213211                }
    214         }
    215 
    216         /**
    217          * Data provider for test_wp_get_webp_info();
     212
     213                $file_data = wp_get_webp_info( $file );
     214                $this->assertSame( $file_data, $expected );
     215        }
     216
     217        /**
     218         * Data provider for test_wp_get_webp_info().
    218219         */
    219220        public function _test_wp_get_webp_info() {
Note: See TracChangeset for help on using the changeset viewer.