Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

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

    r46586 r47122  
    4747
    4848    function test_is_image_positive() {
    49         // these are all image files recognized by php
     49        // These are all image files recognized by PHP.
    5050        $files = array(
    5151            'test-image-cmyk.jpg',
     
    7373
    7474    function test_is_image_negative() {
    75         // these are actually image files but aren't recognized or usable by php
     75        // These are actually image files but aren't recognized or usable by PHP.
    7676        $files = array(
    7777            'test-image.pct',
     
    8686
    8787    function test_is_displayable_image_positive() {
    88         // these are all usable in typical web browsers
     88        // These are all usable in typical web browsers.
    8989        $files = array(
    9090            'test-image.gif',
     
    104104
    105105    function test_is_displayable_image_negative() {
    106         // these are image files but aren't suitable for web pages because of compatibility or size issues
     106        // These are image files but aren't suitable for web pages because of compatibility or size issues.
    107107        $files = array(
    108             // 'test-image-cmyk.jpg', Allowed in r9727
    109             // 'test-image.bmp', Allowed in r28589
    110             // 'test-image-grayscale.jpg', Allowed in r9727
     108            // 'test-image-cmyk.jpg',      Allowed in r9727.
     109            // 'test-image.bmp',           Allowed in r28589.
     110            // 'test-image-grayscale.jpg', Allowed in r9727.
    111111            'test-image.pct',
    112112            'test-image.tga',
     
    136136        include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
    137137
    138         // Mime types
     138        // Mime types.
    139139        $mime_types = array(
    140140            'image/jpeg',
     
    143143        );
    144144
    145         // Test each image editor engine
     145        // Test each image editor engine.
    146146        $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
    147147        foreach ( $classes as $class ) {
    148148
    149             // If the image editor isn't available, skip it
     149            // If the image editor isn't available, skip it.
    150150            if ( ! call_user_func( array( $class, 'test' ) ) ) {
    151151                continue;
     
    155155            $loaded = $img->load();
    156156
    157             // Save a file as each mime type, assert it works
     157            // Save a file as each mime type, assert it works.
    158158            foreach ( $mime_types as $mime_type ) {
    159159                if ( ! $img->supports_mime_type( $mime_type ) ) {
     
    167167                $this->assertEquals( $mime_type, $this->get_mime_type( $ret['path'] ) );
    168168
    169                 // Clean up
     169                // Clean up.
    170170                unlink( $file );
    171171                unlink( $ret['path'] );
    172172            }
    173173
    174             // Clean up
     174            // Clean up.
    175175            unset( $img );
    176176        }
     
    187187        }
    188188
    189         // Test each image editor engine
     189        // Test each image editor engine.
    190190        $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
    191191        foreach ( $classes as $class ) {
    192192
    193             // If the image editor isn't available, skip it
     193            // If the image editor isn't available, skip it.
    194194            if ( ! call_user_func( array( $class, 'test' ) ) ) {
    195195                continue;
     
    199199            $loaded = $img->load();
    200200
    201             // Save the file
     201            // Save the file.
    202202            $mime_type = 'image/gif';
    203203            $file      = wp_tempnam( 'tmp.jpg' );
    204204            $ret       = $img->save( $file, $mime_type );
    205205
    206             // Make assertions
     206            // Make assertions.
    207207            $this->assertNotEmpty( $ret );
    208208            $this->assertNotWPError( $ret );
    209209            $this->assertEquals( $mime_type, $this->get_mime_type( $ret['path'] ) );
    210210
    211             // Clean up
     211            // Clean up.
    212212            unlink( $file );
    213213            unlink( $ret['path'] );
     
    226226        }
    227227
    228         // Mime types
     228        // Mime types.
    229229        $mime_types = array(
    230230            'jpg'  => 'image/jpeg',
     
    233233            'gif'  => 'image/gif',
    234234            'png'  => 'image/png',
    235             'unk'  => 'image/jpeg', // Default, unknown
    236         );
    237 
    238         // Test each image editor engine
     235            'unk'  => 'image/jpeg', // Default, unknown.
     236        );
     237
     238        // Test each image editor engine.
    239239        $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
    240240        foreach ( $classes as $class ) {
    241241
    242             // If the image editor isn't available, skip it
     242            // If the image editor isn't available, skip it.
    243243            if ( ! call_user_func( array( $class, 'test' ) ) ) {
    244244                continue;
     
    248248            $loaded = $img->load();
    249249
    250             // Save the image as each file extension, check the mime type
     250            // Save the image as each file extension, check the mime type.
    251251            $img = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' );
    252252            $this->assertNotWPError( $img );
     
    266266            }
    267267
    268             // Clean up
     268            // Clean up.
    269269            unset( $img );
    270270        }
     
    279279    public function test_load_directory() {
    280280
    281         // First, test with deprecated wp_load_image function
     281        // First, test with deprecated wp_load_image function.
    282282        $editor1 = wp_load_image( DIR_TESTDATA );
    283283        $this->assertNotInternalType( 'resource', $editor1 );
     
    289289        $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
    290290        foreach ( $classes as $class ) {
    291             // If the image editor isn't available, skip it
     291            // If the image editor isn't available, skip it.
    292292            if ( ! call_user_func( array( $class, 'test' ) ) ) {
    293293                continue;
Note: See TracChangeset for help on using the changeset viewer.