Make WordPress Core

Ticket #56248: 56248.patch

File 56248.patch, 11.6 KB (added by martin.krcho, 2 years ago)
  • tests/phpunit/tests/image/intermediateSize.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/tests/phpunit/tests/image/intermediateSize.php b/tests/phpunit/tests/image/intermediateSize.php
    a b  
    1515                parent::tear_down();
    1616        }
    1717
    18         public function _make_attachment( $file, $parent_post_id = 0 ) {
    19                 $contents = file_get_contents( $file );
    20                 $upload   = wp_upload_bits( wp_basename( $file ), null, $contents );
    21 
    22                 return parent::_make_attachment( $upload, $parent_post_id );
    23         }
    24 
    2518        public function test_make_intermediate_size_no_size() {
    2619                $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 0, 0, false );
    2720
     
    9689                add_image_size( 'test-size', 330, 220, true );
    9790
    9891                $file = DIR_TESTDATA . '/images/waffles.jpg';
    99                 $id   = $this->_make_attachment( $file, 0 );
     92                $id   = $this->_upload_file_and_make_attachment( $file );
    10093
    10194                // Look for a size by name.
    10295                $image = image_get_intermediate_size( $id, 'test-size' );
     
    120113                add_image_size( 'false-width', 600, 220, true );
    121114
    122115                $file = DIR_TESTDATA . '/images/waffles.jpg';
    123                 $id   = $this->_make_attachment( $file, 0 );
     116                $id   = $this->_upload_file_and_make_attachment( $file );
    124117
    125118                // Look for a size by array that exists.
    126119                // Note: Staying larger than 300px to miss default medium crop.
     
    143136                add_image_size( 'false-width', 150, 220, true );
    144137
    145138                $file = DIR_TESTDATA . '/images/waffles.jpg';
    146                 $id   = $this->_make_attachment( $file, 0 );
     139                $id   = $this->_upload_file_and_make_attachment( $file );
    147140
    148141                // Look for a size by array that doesn't exist.
    149142                // Note: Staying larger than 300px to miss default medium crop.
     
    165158                add_image_size( 'false-width', 150, 220, true );
    166159
    167160                $file = DIR_TESTDATA . '/images/waffles.jpg';
    168                 $id   = $this->_make_attachment( $file, 0 );
     161                $id   = $this->_upload_file_and_make_attachment( $file );
    169162
    170163                // Look for a size by array that doesn't exist.
    171164                // Note: Staying larger than 300px to miss default medium crop.
     
    189182                add_image_size( 'false-height', $width, 100, true );
    190183
    191184                $file = DIR_TESTDATA . '/images/waffles.jpg';
    192                 $id   = $this->_make_attachment( $file, 0 );
     185                $id   = $this->_upload_file_and_make_attachment( $file );
    193186
    194187                $original = wp_get_attachment_metadata( $id );
    195188                $image_w  = $width;
     
    218211                add_image_size( 'false-height', 300, $height, true );
    219212
    220213                $file = DIR_TESTDATA . '/images/waffles.jpg';
    221                 $id   = $this->_make_attachment( $file, 0 );
     214                $id   = $this->_upload_file_and_make_attachment( $file );
    222215
    223216                $original = wp_get_attachment_metadata( $id );
    224217                $image_h  = $height;
     
    245238                add_image_size( 'off-by-one', $width, $height, true );
    246239
    247240                $file = DIR_TESTDATA . '/images/waffles.jpg';
    248                 $id   = $this->_make_attachment( $file, 0 );
     241                $id   = $this->_upload_file_and_make_attachment( $file );
    249242
    250243                $original = wp_get_attachment_metadata( $id );
    251244                $image_h  = $height;
     
    267260                add_image_size( 'test-size', 200, 100, true );
    268261
    269262                $file = DIR_TESTDATA . '/images/waffles.jpg';
    270                 $id   = $this->_make_attachment( $file, 0 );
     263                $id   = $this->_upload_file_and_make_attachment( $file );
    271264
    272265                // Request a size by array that doesn't exist and is smaller than the 'thumbnail'.
    273266                $image = image_get_intermediate_size( $id, array( 50, 25 ) );
     
    282275         */
    283276        public function test_get_intermediate_size_with_small_size_array_fallback() {
    284277                $file = DIR_TESTDATA . '/images/waffles.jpg';
    285                 $id   = $this->_make_attachment( $file, 0 );
     278                $id   = $this->_upload_file_and_make_attachment( $file );
    286279
    287280                $original       = wp_get_attachment_metadata( $id );
    288281                $thumbnail_file = $original['sizes']['thumbnail']['file'];
  • tests/phpunit/tests/image/siteIcon.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/tests/phpunit/tests/image/siteIcon.php b/tests/phpunit/tests/image/siteIcon.php
    a b  
    160160                        return $this->attachment_id;
    161161                }
    162162
    163                 $filename = DIR_TESTDATA . '/images/test-image.jpg';
    164                 $contents = file_get_contents( $filename );
    165 
    166                 $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    167 
    168                 $this->attachment_id = $this->_make_attachment( $upload );
     163                $this->attachment_id = $this->_upload_file_and_make_attachment( DIR_TESTDATA . '/images/test-image.jpg' );
    169164                return $this->attachment_id;
    170165        }
    171166}
  • tests/phpunit/tests/ajax/Attachments.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/tests/phpunit/tests/ajax/Attachments.php b/tests/phpunit/tests/ajax/Attachments.php
    a b  
    2020                // Become an administrator.
    2121                $this->_setRole( 'administrator' );
    2222
    23                 $filename = DIR_TESTDATA . '/images/canola.jpg';
    24                 $contents = file_get_contents( $filename );
    25 
    26                 $upload     = wp_upload_bits( wp_basename( $filename ), null, $contents );
    27                 $attachment = $this->_make_attachment( $upload );
     23                $attachment = $this->_upload_file_and_make_attachment( DIR_TESTDATA . '/images/canola.jpg' );
    2824
    2925                // Set up a default request.
    3026                $_POST['nonce']      = wp_create_nonce( 'media-send-to-editor' );
     
    6763                // Become an administrator.
    6864                $this->_setRole( 'administrator' );
    6965
    70                 $filename = DIR_TESTDATA . '/formatting/entities.txt';
    71                 $contents = file_get_contents( $filename );
    72 
    73                 $upload     = wp_upload_bits( wp_basename( $filename ), null, $contents );
    74                 $attachment = $this->_make_attachment( $upload );
     66                $attachment = $this->_upload_file_and_make_attachment( DIR_TESTDATA . '/formatting/entities.txt' );
    7567
    7668                // Set up a default request.
    7769                $_POST['nonce']      = wp_create_nonce( 'media-send-to-editor' );
  • tests/phpunit/includes/abstract-testcase.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php
    a b  
    15071507                return $id;
    15081508        }
    15091509
     1510        /**
     1511         * Uploads given file and creates an attachment post from it.
     1512         *
     1513         * @since 6.1.0
     1514         *
     1515         * @param array $filename       Absolute path to the file to upload.
     1516         * @param int   $parent_post_id Optional. Parent post ID.
     1517         *
     1518         * @return int|WP_Error The attachment ID on success. The value 0 or WP_Error on failure.
     1519         */
     1520        public function _upload_file_and_make_attachment( $filename, $parent_post_id = 0 ) {
     1521                $contents = file_get_contents( $filename );
     1522                $upload   = wp_upload_bits( wp_basename( $filename ), null, $contents );
     1523
     1524                return $this->_make_attachment( $upload, $parent_post_id );
     1525        }
     1526
    15101527        /**
    15111528         * Updates the modified and modified GMT date of a post in the database.
    15121529         *
  • tests/phpunit/tests/post/attachments.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/tests/phpunit/tests/post/attachments.php b/tests/phpunit/tests/post/attachments.php
    a b  
    441441        }
    442442
    443443        public function test_wp_attachment_is() {
    444                 $filename = DIR_TESTDATA . '/images/test-image.jpg';
    445                 $contents = file_get_contents( $filename );
    446 
    447                 $upload        = wp_upload_bits( wp_basename( $filename ), null, $contents );
    448                 $attachment_id = $this->_make_attachment( $upload );
     444                $attachment_id = $this->_upload_file_and_make_attachment( DIR_TESTDATA . '/images/test-image.jpg' );
    449445
    450446                $this->assertTrue( wp_attachment_is_image( $attachment_id ) );
    451447                $this->assertTrue( wp_attachment_is( 'image', $attachment_id ) );
     
    459455                        add_filter( 'upload_mimes', array( $this, 'allow_psd_mime_type' ), 10, 2 );
    460456                }
    461457
    462                 $filename = DIR_TESTDATA . '/images/test-image.psd';
    463                 $contents = file_get_contents( $filename );
    464 
    465                 $upload        = wp_upload_bits( wp_basename( $filename ), null, $contents );
    466                 $attachment_id = $this->_make_attachment( $upload );
     458                $attachment_id = $this->_upload_file_and_make_attachment( DIR_TESTDATA . '/images/test-image.psd' );
    467459
    468460                $this->assertFalse( wp_attachment_is_image( $attachment_id ) );
    469461                $this->assertTrue( wp_attachment_is( 'psd', $attachment_id ) );
  • tests/phpunit/tests/xmlrpc/wp/getMediaItem.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php b/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php
    a b  
    1919
    2020                add_theme_support( 'post-thumbnails' );
    2121
    22                 $filename = ( DIR_TESTDATA . '/images/waffles.jpg' );
    23                 $contents = file_get_contents( $filename );
    24                 $upload   = wp_upload_bits( wp_basename( $filename ), null, $contents );
    25 
    26                 $this->attachment_id   = $this->_make_attachment( $upload, self::$post_id );
     22                $this->attachment_id   = $this->_upload_file_and_make_attachment( DIR_TESTDATA . '/images/waffles.jpg', self::$post_id );
    2723                $this->attachment_data = get_post( $this->attachment_id, ARRAY_A );
    2824
    2925                set_post_thumbnail( self::$post_id, $this->attachment_id );
  • tests/phpunit/tests/ajax/MediaEdit.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/tests/phpunit/tests/ajax/MediaEdit.php b/tests/phpunit/tests/ajax/MediaEdit.php
    a b  
    3535        public function testCropImageThumbnail() {
    3636                require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    3737
    38                 $filename = DIR_TESTDATA . '/images/canola.jpg';
    39                 $contents = file_get_contents( $filename );
    40 
    41                 $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    42                 $id     = $this->_make_attachment( $upload );
     38                $id     = $this->_upload_file_and_make_attachment( DIR_TESTDATA . '/images/canola.jpg' );
    4339
    4440                $_REQUEST['action']  = 'image-editor';
    4541                $_REQUEST['context'] = 'edit-attachment';
     
    7066
    7167                require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    7268
    73                 $filename = DIR_TESTDATA . '/images/canola.jpg';
    74                 $contents = file_get_contents( $filename );
    75 
    76                 $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
    77                 $id     = $this->_make_attachment( $upload );
     69                $id     = $this->_make_attachment( DIR_TESTDATA . '/images/canola.jpg' );
    7870
    7971                $_REQUEST['action']  = 'image-editor';
    8072                $_REQUEST['context'] = 'edit-attachment';