Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (7 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/media.php

    r47010 r47122  
    273273                return array(
    274274
    275                         // Should embed
     275                        // Should embed.
    276276                        array(
    277277                                'https://w.org',
    … …  
    309309                        ),
    310310
    311                         // Should NOT embed
     311                        // Should NOT embed.
    312312                        array(
    313313                                'test https://w.org</p>',
    … …  
    337337
    338338        function test_wp_prepare_attachment_for_js() {
    339                 // Attachment without media
     339                // Attachment without media.
    340340                $id   = wp_insert_attachment(
    341341                        array(
    … …  
    354354                $this->assertEquals( '', $prepped['type'] );
    355355                $this->assertEquals( '', $prepped['subtype'] );
    356                 // #21963, there will be a guid always, so there will be a URL
     356                // #21963, there will be a GUID always, so there will be a URL.
    357357                $this->assertNotEquals( '', $prepped['url'] );
    358358                $this->assertEquals( site_url( 'wp-includes/images/media/default.png' ), $prepped['icon'] );
    359359
    360                 // Fake a mime
     360                // Fake a mime.
    361361                $post->post_mime_type = 'image/jpeg';
    362362                $prepped              = wp_prepare_attachment_for_js( $post );
    … …  
    365365                $this->assertEquals( 'jpeg', $prepped['subtype'] );
    366366
    367                 // Fake a mime without a slash. See #WP22532
     367                // Fake a mime without a slash. See #WP22532.
    368368                $post->post_mime_type = 'image';
    369369                $prepped              = wp_prepare_attachment_for_js( $post );
    … …  
    427427                $tb = $gb * 1024;
    428428
    429                 // test if boundaries are correct
     429                // Test if boundaries are correct.
    430430                $this->assertEquals( '1TB', wp_convert_bytes_to_hr( $tb ) );
    431431                $this->assertEquals( '1GB', wp_convert_bytes_to_hr( $gb ) );
    … …  
    438438                $this->assertEquals( '1 KB', size_format( $kb ) );
    439439
    440                 // now some values around
     440                // Now some values around.
    441441                $hr = wp_convert_bytes_to_hr( $tb + $tb / 2 + $mb );
    442442                $this->assertEquals( 1.50000095367, (float) str_replace( ',', '.', $hr ), 'The values should be equal', 0.0001 );
    … …  
    451451                $this->assertEquals( 1022.99902344, (float) str_replace( ',', '.', $hr ), 'The values should be equal', 0.0001 );
    452452
    453                 // edge
     453                // Edge.
    454454                $this->assertEquals( '-1B', wp_convert_bytes_to_hr( -1 ) );
    455455                $this->assertEquals( '0B', wp_convert_bytes_to_hr( 0 ) );
    … …  
    613613                $galleries = get_post_galleries( $post_id_two, false );
    614614
    615                 // Set the global $post context
     615                // Set the global $post context.
    616616                $GLOBALS['post']               = get_post( $post_id_two );
    617617                $galleries_with_global_context = get_post_galleries( $post_id_two, false );
    618618
    619                 // Check that the global post state doesn't affect the results
     619                // Check that the global post state doesn't affect the results.
    620620                $this->assertSame( $galleries, $galleries_with_global_context );
    621621
    … …  
    10121012                $sizes = wp_get_additional_image_sizes();
    10131013
    1014                 // Clean up
     1014                // Clean up.
    10151015                remove_image_size( 'test-size' );
    10161016
    … …  
    10371037                $this->assertTrue( has_image_size( 'test-size' ) );
    10381038
    1039                 // Clean up
     1039                // Clean up.
    10401040                remove_image_size( 'test-size' );
    10411041        }
    … …  
    11421142                $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg';
    11431143
    1144                 // Make a copy of this file as it gets moved during the file upload
     1144                // Make a copy of this file as it gets moved during the file upload.
    11451145                $tmp_name = wp_tempnam( $iptc_file );
    11461146
    … …  
    11811181                $test_file = DIR_TESTDATA . '/images/test-image.jpg';
    11821182
    1183                 // Make a copy of this file as it gets moved during the file upload
     1183                // Make a copy of this file as it gets moved during the file upload.
    11841184                $tmp_name = wp_tempnam( $test_file );
    11851185
    … …  
    14971497                $_wp_additional_image_sizes = wp_get_additional_image_sizes();
    14981498
    1499                 // Disable date organized uploads
     1499                // Disable date organized uploads.
    15001500                add_filter( 'upload_dir', '_upload_dir_no_subdir' );
    15011501
    … …  
    15351535                }
    15361536
    1537                 // Remove the attachment
     1537                // Remove the attachment.
    15381538                wp_delete_attachment( $id );
    15391539                remove_filter( 'upload_dir', '_upload_dir_no_subdir' );
    … …  
    15551555                $filename_base = wp_basename( $image_meta['file'], '.png' );
    15561556
    1557                 // Add the hash to the image URL
     1557                // Add the hash to the image URL.
    15581558                $image_url = str_replace( $filename_base, $filename_base . '-' . $hash, $image_url );
    15591559
    … …  
    16051605                $expected .= $uploads_dir_url . $image_meta['file'] . ' ' . $image_meta['width'] . 'w';
    16061606
    1607                 // Prepend an absolute path to simulate a pre-2.7 upload
     1607                // Prepend an absolute path to simulate a pre-2.7 upload.
    16081608                $image_meta['file'] = 'H:\home\wordpress\trunk/wp-content/uploads/' . $image_meta['file'];
    16091609
    … …  
    16221622                $sizes = wp_calculate_image_srcset( array( 400, 300 ), 'file.png', array() );
    16231623
    1624                 // For canola.jpg we should return
     1624                // For canola.jpg we should return.
    16251625                $this->assertFalse( $sizes );
    16261626        }
    … …  
    17771777                );
    17781778
    1779                 // No sizes array
     1779                // No sizes array.
    17801780                $image_meta1 = $image_meta;
    17811781                unset( $image_meta1['sizes'] );
    … …  
    17871787                $this->assertFalse( wp_calculate_image_srcset( $size_array, $image_src, $image_meta2 ) );
    17881788
    1789                 // File name is incorrect
     1789                // File name is incorrect.
    17901790                $image_meta3         = $image_meta;
    17911791                $image_meta3['file'] = '/';
    17921792                $this->assertFalse( wp_calculate_image_srcset( $size_array, $image_src, $image_meta3 ) );
    17931793
    1794                 // File name is incorrect
     1794                // File name is incorrect.
    17951795                $image_meta4 = $image_meta;
    17961796                unset( $image_meta4['file'] );
    … …  
    18561856
    18571857                $image_meta = wp_get_attachment_metadata( self::$large_id );
    1858                 $size_array = array( 1600, 1200 ); // full size
     1858                $size_array = array( 1600, 1200 ); // Full size.
    18591859
    18601860                $srcset = wp_get_attachment_image_srcset( self::$large_id, $size_array, $image_meta );
    … …  
    19821982                $img_html5            = str_replace( ' />', '>', $img );
    19831983
    1984                 // Manually add srcset and sizes to the markup from get_image_tag();
     1984                // Manually add srcset and sizes to the markup from get_image_tag().
    19851985                $respimg                  = preg_replace( '|<img ([^>]+) />|', '<img $1 ' . $srcset . ' ' . $sizes . ' />', $img );
    19861986                $respimg_no_size_in_class = preg_replace( '|<img ([^>]+) />|', '<img $1 ' . $srcset . ' ' . $sizes . ' />', $img_no_size_in_class );
    … …  
    20322032                $image = get_image_tag( self::$large_id, '', '', '', 'medium' );
    20332033
    2034                 // Replace the src URL
     2034                // Replace the src URL.
    20352035                $image_wrong_src = preg_replace( '|src="[^"]+"|', 'src="http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/foo.jpg"', $image );
    20362036
    … …  
    24332433                $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg';
    24342434
    2435                 // Make a copy of this file as it gets moved during the file upload
     2435                // Make a copy of this file as it gets moved during the file upload.
    24362436                $tmp_name = wp_tempnam( $iptc_file );
    24372437
    … …  
    24792479                $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg';
    24802480
    2481                 // Make a copy of this file as it gets moved during the file upload
     2481                // Make a copy of this file as it gets moved during the file upload.
    24822482                $tmp_name = wp_tempnam( $iptc_file );
    24832483
Note: See TracChangeset for help on using the changeset viewer.