Make WordPress Core

Changeset 53852


Ignore:
Timestamp:
08/07/2022 02:32:55 PM (22 months ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Remove dynamic properties in Tests_Media_GetPostGalleries.

Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this particular case, the test class contains a set_up() method that sets the $img_meta property, which is used by the tests, but never changed by the tests.

In other words, setting this property in the set_up() is an unnecessary overhead and the property should be changed to a class constant.

Includes renaming the test class to match the naming conventions.

Follow-up to [52190], [53557], [53558], [53850], [53851].

Props jrf.
See #56033.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/media/getPostGalleries.php

    r52984 r53852  
    55 * @covers ::get_post_galleries
    66 */
    7 class Tests_Functions_getPostGalleries extends WP_UnitTestCase {
    8 
    9     public function set_up() {
    10         parent::set_up();
    11         $this->img_meta = array(
    12             'width'  => 100,
    13             'height' => 100,
    14             'sizes'  => '',
    15         );
    16     }
     7class Tests_Media_GetPostGalleries extends WP_UnitTestCase {
     8
     9    const IMG_META = array(
     10        'width'  => 100,
     11        'height' => 100,
     12        'sizes'  => '',
     13    );
    1714
    1815    /**
     
    570567                )
    571568            );
    572             $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
     569            $metadata      = array_merge( array( 'file' => "image$i.jpg" ), self::IMG_META );
    573570            wp_update_attachment_metadata( $attachment_id, $metadata );
    574571            $ids[]      = $attachment_id;
     
    659656            )
    660657        );
    661         $metadata       = array_merge( array( 'file' => 'image1.jpg' ), $this->img_meta );
     658        $metadata       = array_merge( array( 'file' => 'image1.jpg' ), self::IMG_META );
    662659        $url            = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . 'image1.jpg';
    663660        $global_post_id = $this->factory->post->create(
     
    839836                )
    840837            );
    841             $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
     838            $metadata      = array_merge( array( 'file' => "image$i.jpg" ), self::IMG_META );
    842839            wp_update_attachment_metadata( $attachment_id, $metadata );
    843840            $ids[]      = $attachment_id;
     
    903900                )
    904901            );
    905             $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
     902            $metadata      = array_merge( array( 'file' => "image$i.jpg" ), self::IMG_META );
    906903            wp_update_attachment_metadata( $attachment_id, $metadata );
    907904            $ids[]      = $attachment_id;
Note: See TracChangeset for help on using the changeset viewer.