WordPress.org

Make WordPress Core

Changeset 52248


Ignore:
Timestamp:
11/25/2021 07:39:31 PM (9 days ago)
Author:
johnbillion
Message:

Build/Test Tools: Correct the order and naming of expected and actual values in various tests.

This corrects the order of the parameters when used in assertions so if/when they fail the failure message is correct.

See #53363

Location:
trunk/tests/phpunit/tests
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/db/charset.php

    r52010 r52248  
    768768
    769769        $charset = self::$_wpdb->get_table_charset( $table );
    770         $this->assertSame( $charset, $expected_charset );
     770        $this->assertSame( $expected_charset, $charset );
    771771
    772772        $charset = self::$_wpdb->get_table_charset( strtoupper( $table ) );
    773         $this->assertSame( $charset, $expected_charset );
     773        $this->assertSame( $expected_charset, $charset );
    774774
    775775        self::$_wpdb->query( $drop );
  • trunk/tests/phpunit/tests/image/editor.php

    r51704 r52248  
    298298
    299299        $file_data = wp_get_webp_info( $file );
    300         $this->assertSame( $file_data, $expected );
     300        $this->assertSame( $expected, $file_data );
    301301    }
    302302
  • trunk/tests/phpunit/tests/image/functions.php

    r52010 r52248  
    627627        $metadata = wp_generate_attachment_metadata( $attachment_id, $test_file );
    628628        $this->assertArrayHasKey( 'test-size', $metadata['sizes'], 'The `test-size` was not added to the metadata.' );
    629         $this->assertSame( $metadata['sizes']['test-size'], $expected );
     629        $this->assertSame( $expected, $metadata['sizes']['test-size'] );
    630630
    631631        remove_image_size( 'test-size' );
  • trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php

    r51568 r52248  
    7070
    7171        $is_textdomain_loaded_before = is_textdomain_loaded( 'internationalized-plugin' );
    72         $expected_output             = i18n_plugin_test();
     72        $actual_output               = i18n_plugin_test();
    7373        $is_textdomain_loaded_after  = is_textdomain_loaded( 'internationalized-plugin' );
    7474
     
    7676
    7777        $this->assertFalse( $is_textdomain_loaded_before );
    78         $this->assertSame( 'Das ist ein Dummy Plugin', $expected_output );
     78        $this->assertSame( 'Das ist ein Dummy Plugin', $actual_output );
    7979        $this->assertTrue( $is_textdomain_loaded_after );
    8080    }
     
    9191
    9292        $is_textdomain_loaded_before = is_textdomain_loaded( 'internationalized-theme' );
    93         $expected_output             = i18n_theme_test();
     93        $actual_output               = i18n_theme_test();
    9494        $is_textdomain_loaded_after  = is_textdomain_loaded( 'internationalized-theme' );
    9595
     
    9797
    9898        $this->assertFalse( $is_textdomain_loaded_before );
    99         $this->assertSame( 'Das ist ein Dummy Theme', $expected_output );
     99        $this->assertSame( 'Das ist ein Dummy Theme', $actual_output );
    100100        $this->assertTrue( $is_textdomain_loaded_after );
    101101    }
     
    122122        require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php';
    123123
    124         $expected_output_before      = i18n_plugin_test();
     124        $actual_output_before        = i18n_plugin_test();
    125125        $is_textdomain_loaded_before = is_textdomain_loaded( 'internationalized-plugin' );
    126126
     
    128128        remove_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
    129129
    130         $expected_output_after      = i18n_plugin_test();
     130        $actual_output_after        = i18n_plugin_test();
    131131        $is_textdomain_loaded_after = is_textdomain_loaded( 'internationalized-plugin' );
    132132
     
    134134        load_textdomain( 'internationalized-plugin', WP_LANG_DIR . '/plugins/internationalized-plugin-de_DE.mo' );
    135135
    136         $expected_output_final      = i18n_plugin_test();
     136        $actual_output_final        = i18n_plugin_test();
    137137        $is_textdomain_loaded_final = is_textdomain_loaded( 'internationalized-plugin' );
    138138
     
    141141
    142142        // Text domain loaded just in time.
    143         $this->assertSame( 'Das ist ein Dummy Plugin', $expected_output_before );
     143        $this->assertSame( 'Das ist ein Dummy Plugin', $actual_output_before );
    144144        $this->assertTrue( $is_textdomain_loaded_before );
    145145
    146146        // Text domain unloaded.
    147         $this->assertSame( 'This is a dummy plugin', $expected_output_after );
     147        $this->assertSame( 'This is a dummy plugin', $actual_output_after );
    148148        $this->assertFalse( $is_textdomain_loaded_after );
    149149
    150150        // Text domain loaded manually again.
    151         $this->assertSame( 'Das ist ein Dummy Plugin', $expected_output_final );
     151        $this->assertSame( 'Das ist ein Dummy Plugin', $actual_output_final );
    152152        $this->assertTrue( $is_textdomain_loaded_final );
    153153    }
     
    160160
    161161        switch_to_locale( 'de_DE' );
    162         $expected = i18n_plugin_test();
     162        $actual = i18n_plugin_test();
    163163        restore_previous_locale();
    164164
    165         $this->assertSame( 'Das ist ein Dummy Plugin', $expected );
     165        $this->assertSame( 'Das ist ein Dummy Plugin', $actual );
    166166    }
    167167
     
    173173
    174174        switch_to_locale( 'de_DE' );
    175         $expected_de_de = i18n_plugin_test();
     175        $actual_de_de = i18n_plugin_test();
    176176
    177177        switch_to_locale( 'es_ES' );
    178         $expected_es_es = i18n_plugin_test();
     178        $actual_es_es = i18n_plugin_test();
    179179
    180180        restore_current_locale();
    181181
    182         $this->assertSame( 'Das ist ein Dummy Plugin', $expected_de_de );
    183         $this->assertSame( 'This is a dummy plugin', $expected_es_es );
     182        $this->assertSame( 'Das ist ein Dummy Plugin', $actual_de_de );
     183        $this->assertSame( 'This is a dummy plugin', $actual_es_es );
    184184    }
    185185
     
    193193
    194194        switch_to_locale( 'de_DE' );
    195         $expected = i18n_theme_test();
     195        $actual = i18n_theme_test();
    196196        restore_previous_locale();
    197197
    198198        switch_theme( WP_DEFAULT_THEME );
    199199
    200         $this->assertSame( 'Das ist ein Dummy Theme', $expected );
     200        $this->assertSame( 'Das ist ein Dummy Theme', $actual );
    201201    }
    202202
     
    210210        wp_set_current_user( self::$user_id );
    211211
    212         $expected = i18n_plugin_test();
    213 
    214         $this->assertSame( 'Das ist ein Dummy Plugin', $expected );
     212        $actual = i18n_plugin_test();
     213
     214        $this->assertSame( 'Das ist ein Dummy Plugin', $actual );
    215215    }
    216216
     
    225225        require_once get_stylesheet_directory() . '/functions.php';
    226226
    227         $expected = i18n_theme_test();
     227        $actual = i18n_theme_test();
    228228
    229229        switch_theme( WP_DEFAULT_THEME );
    230230
    231         $this->assertSame( 'Das ist ein Dummy Theme', $expected );
     231        $this->assertSame( 'Das ist ein Dummy Theme', $actual );
    232232    }
    233233
  • trunk/tests/phpunit/tests/l10n/wpLocaleSwitcher.php

    r51568 r52248  
    373373        switch_to_locale( $site_locale );
    374374
    375         $expected = i18n_plugin_test();
     375        $actual = i18n_plugin_test();
    376376
    377377        restore_current_locale();
     
    380380
    381381        $this->assertSame( 'en_US', get_locale() );
    382         $this->assertSame( 'This is a dummy plugin', $expected );
     382        $this->assertSame( 'This is a dummy plugin', $actual );
    383383    }
    384384
  • trunk/tests/phpunit/tests/menu/walker-nav-menu.php

    r51657 r52248  
    4242     */
    4343    public function test_noopener_no_referrer_for_target_blank() {
    44         $expected   = '';
     44        $actual     = '';
    4545        $post_id    = $this->factory->post->create();
    4646        $post_title = get_the_title( $post_id );
     
    6262        );
    6363
    64         $this->walker->start_el( $expected, (object) $item, 0, (object) $args );
     64        $this->walker->start_el( $actual, (object) $item, 0, (object) $args );
    6565
    66         $this->assertSame( "<li id=\"menu-item-{$post_id}\" class=\"menu-item-{$post_id}\"><a target=\"_blank\" rel=\"noopener\">{$post_title}</a>", $expected );
     66        $this->assertSame( "<li id=\"menu-item-{$post_id}\" class=\"menu-item-{$post_id}\"><a target=\"_blank\" rel=\"noopener\">{$post_title}</a>", $actual );
    6767    }
    6868
  • trunk/tests/phpunit/tests/meta/registerMeta.php

    r49603 r52248  
    180180            ),
    181181        );
    182         $this->assertSame( $actual, $expected );
     182        $this->assertSame( $expected, $actual );
    183183    }
    184184
     
    522522        $object_id            = self::$$object_property_name;
    523523        $default_value        = get_metadata_default( $object_type, $object_id, $meta_key, $single );
    524         $this->assertSame( $default_value, $expected );
     524        $this->assertSame( $expected, $default_value );
    525525
    526526        // Check for default value.
    527527        $value = get_metadata( $object_type, $object_id, $meta_key, $single );
    528         $this->assertSame( $value, $expected );
     528        $this->assertSame( $expected, $value );
    529529
    530530        // Set value to check default is not being returned by mistake.
     
    537537        delete_metadata( $object_type, $object_id, $meta_key );
    538538        $value = get_metadata( $object_type, $object_id, $meta_key, $single );
    539         $this->assertSame( $value, $expected );
     539        $this->assertSame( $expected, $value );
    540540
    541541        // Set other meta key, to make sure other keys are not effects.
     
    569569        $object_id            = self::$$object_property_name;
    570570        $default_value        = get_metadata_default( $object_type, $object_id, $meta_key, $single );
    571         $this->assertSame( $default_value, $expected );
     571        $this->assertSame( $expected, $default_value );
    572572    }
    573573
  • trunk/tests/phpunit/tests/post/nav-menu.php

    r52010 r52248  
    248248        $nav_menus_names = wp_list_pluck( wp_get_nav_menus(), 'name' );
    249249
    250         $this->assertSame( $nav_menus_names, $expected_nav_menus_names );
     250        $this->assertSame( $expected_nav_menus_names, $nav_menus_names );
    251251    }
    252252
  • trunk/tests/phpunit/tests/query/commentCount.php

    r51568 r52248  
    8282        $expected = self::$post_ids[4];
    8383
    84         $this->assertSameSets( $found_post_ids, $expected );
     84        $this->assertSameSets( $expected, $found_post_ids );
    8585    }
    8686
     
    100100        $expected = self::$post_ids[5];
    101101
    102         $this->assertSameSets( $found_post_ids, $expected );
     102        $this->assertSameSets( $expected, $found_post_ids );
    103103    }
    104104
     
    118118        $expected = array();
    119119
    120         $this->assertSameSets( $found_post_ids, $expected );
     120        $this->assertSameSets( $expected, $found_post_ids );
    121121    }
    122122    public function test_operator_less_than() {
     
    144144        }
    145145
    146         $this->assertSameSets( $found_post_ids, $expected );
     146        $this->assertSameSets( $expected, $found_post_ids );
    147147    }
    148148
     
    162162        $expected = array();
    163163
    164         $this->assertSameSets( $found_post_ids, $expected );
     164        $this->assertSameSets( $expected, $found_post_ids );
    165165    }
    166166
     
    190190        }
    191191
    192         $this->assertSameSets( $found_post_ids, $expected );
     192        $this->assertSameSets( $expected, $found_post_ids );
    193193
    194194    }
     
    214214        }
    215215
    216         $this->assertSameSets( $found_post_ids, $expected );
     216        $this->assertSameSets( $expected, $found_post_ids );
    217217    }
    218218
     
    232232        $expected = array();
    233233
    234         $this->assertSameSets( $found_post_ids, $expected );
     234        $this->assertSameSets( $expected, $found_post_ids );
    235235    }
    236236
     
    256256        }
    257257
    258         $this->assertSameSets( $found_post_ids, $expected );
     258        $this->assertSameSets( $expected, $found_post_ids );
    259259    }
    260260
     
    274274        $expected = array();
    275275
    276         $this->assertSameSets( $found_post_ids, $expected );
     276        $this->assertSameSets( $expected, $found_post_ids );
    277277    }
    278278
     
    295295        }
    296296
    297         $this->assertSameSets( $found_post_ids, $expected );
     297        $this->assertSameSets( $expected, $found_post_ids );
    298298    }
    299299
     
    313313        $expected = array();
    314314
    315         $this->assertSameSets( $found_post_ids, $expected );
     315        $this->assertSameSets( $expected, $found_post_ids );
    316316    }
    317317
     
    330330        $expected = self::$post_ids[5];
    331331
    332         $this->assertSameSets( $found_post_ids, $expected );
     332        $this->assertSameSets( $expected, $found_post_ids );
    333333    }
    334334
     
    354354        }
    355355
    356         $this->assertSameSets( $found_post_ids, $expected );
     356        $this->assertSameSets( $expected, $found_post_ids );
    357357    }
    358358
     
    369369        $expected = self::$post_ids[5];
    370370
    371         $this->assertSameSets( $found_post_ids, $expected );
     371        $this->assertSameSets( $expected, $found_post_ids );
    372372    }
    373373}
  • trunk/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php

    r52184 r52248  
    393393            $actual[]   = $data['menu_order'];
    394394        }
    395         $this->assertSame( $actual, $expected );
     395        $this->assertSame( $expected, $actual );
    396396    }
    397397
  • trunk/tests/phpunit/tests/widgets/wpWidgetCustomHtml.php

    r52010 r52248  
    186186        );
    187187        $result   = $widget->update( $instance, array() );
    188         $this->assertSame( $result, $expected );
     188        $this->assertSame( $expected, $result );
    189189
    190190        // Make sure KSES is applying as expected.
     
    194194        $expected['content'] = $instance['content'];
    195195        $result              = $widget->update( $instance, array() );
    196         $this->assertSame( $result, $expected );
     196        $this->assertSame( $expected, $result );
    197197        remove_filter( 'map_meta_cap', array( $this, 'grant_unfiltered_html_cap' ) );
    198198
     
    202202        $expected['content'] = wp_kses_post( $instance['content'] );
    203203        $result              = $widget->update( $instance, array() );
    204         $this->assertSame( $result, $expected );
     204        $this->assertSame( $expected, $result );
    205205        remove_filter( 'map_meta_cap', array( $this, 'revoke_unfiltered_html_cap' ), 10 );
    206206    }
  • trunk/tests/phpunit/tests/widgets/wpWidgetMedia.php

    r52010 r52248  
    245245        );
    246246        $result   = $widget->update( $expected, $instance );
    247         $this->assertSame( $result, $expected );
     247        $this->assertSame( $expected, $result );
    248248
    249249        // Should filter invalid attachment ID.
     
    261261        );
    262262        $result   = $widget->update( $expected, $instance );
    263         $this->assertSame( $result, $expected );
     263        $this->assertSame( $expected, $result );
    264264
    265265        // Should filter invalid attachment url.
     
    277277        );
    278278        $result   = $widget->update( $expected, $instance );
    279         $this->assertSame( $result, $expected );
     279        $this->assertSame( $expected, $result );
    280280
    281281        // Should filter invalid attachment title.
  • trunk/tests/phpunit/tests/widgets/wpWidgetMediaAudio.php

    r52010 r52248  
    126126        );
    127127        $result   = $widget->update( $expected, $instance );
    128         $this->assertSame( $result, $expected );
     128        $this->assertSame( $expected, $result );
    129129
    130130        // Should filter invalid attachment ID.
     
    142142        );
    143143        $result   = $widget->update( $expected, $instance );
    144         $this->assertSame( $result, $expected );
     144        $this->assertSame( $expected, $result );
    145145
    146146        // Should filter invalid attachment url.
     
    159159        );
    160160        $result   = $widget->update( $expected, $instance );
    161         $this->assertSame( $result, $expected );
     161        $this->assertSame( $expected, $result );
    162162
    163163        // Should filter invalid loop setting.
     
    175175        );
    176176        $result   = $widget->update( $expected, $instance );
    177         $this->assertSame( $result, $expected );
     177        $this->assertSame( $expected, $result );
    178178
    179179        // Should filter invalid attachment title.
     
    191191        );
    192192        $result   = $widget->update( $expected, $instance );
    193         $this->assertSame( $result, $expected );
     193        $this->assertSame( $expected, $result );
    194194
    195195        // Should filter invalid preload setting.
  • trunk/tests/phpunit/tests/widgets/wpWidgetMediaImage.php

    r52010 r52248  
    133133        );
    134134        $result   = $widget->update( $expected, $instance );
    135         $this->assertSame( $result, $expected );
     135        $this->assertSame( $expected, $result );
    136136
    137137        // Should filter invalid attachment ID.
     
    149149        );
    150150        $result   = $widget->update( $expected, $instance );
    151         $this->assertSame( $result, $expected );
     151        $this->assertSame( $expected, $result );
    152152
    153153        // Should filter invalid attachment url.
     
    166166        );
    167167        $result   = $widget->update( $expected, $instance );
    168         $this->assertSame( $result, $expected );
     168        $this->assertSame( $expected, $result );
    169169
    170170        // Should filter invalid attachment title.
     
    182182        );
    183183        $result   = $widget->update( $expected, $instance );
    184         $this->assertSame( $result, $expected );
     184        $this->assertSame( $expected, $result );
    185185
    186186        // Should filter invalid image size.
     
    198198        );
    199199        $result   = $widget->update( $expected, $instance );
    200         $this->assertSame( $result, $expected );
     200        $this->assertSame( $expected, $result );
    201201
    202202        // Should filter invalid image width.
     
    214214        );
    215215        $result   = $widget->update( $expected, $instance );
    216         $this->assertSame( $result, $expected );
     216        $this->assertSame( $expected, $result );
    217217
    218218        // Should filter invalid image height.
     
    230230        );
    231231        $result   = $widget->update( $expected, $instance );
    232         $this->assertSame( $result, $expected );
     232        $this->assertSame( $expected, $result );
    233233
    234234        // Should filter invalid image caption.
     
    251251        );
    252252        $result   = $widget->update( $expected, $instance );
    253         $this->assertSame( $result, $expected );
     253        $this->assertSame( $expected, $result );
    254254
    255255        // Should filter invalid alt text.
     
    272272        );
    273273        $result   = $widget->update( $expected, $instance );
    274         $this->assertSame( $result, $expected );
     274        $this->assertSame( $expected, $result );
    275275
    276276        // Should filter invalid link type.
     
    288288        );
    289289        $result   = $widget->update( $expected, $instance );
    290         $this->assertSame( $result, $expected );
     290        $this->assertSame( $expected, $result );
    291291
    292292        // Should filter invalid link url.
     
    305305        );
    306306        $result   = $widget->update( $expected, $instance );
    307         $this->assertSame( $result, $expected );
     307        $this->assertSame( $expected, $result );
    308308
    309309        // Should filter invalid image classes.
     
    326326        );
    327327        $result   = $widget->update( $expected, $instance );
    328         $this->assertSame( $result, $expected );
     328        $this->assertSame( $expected, $result );
    329329
    330330        // Should filter invalid link classes.
     
    347347        );
    348348        $result   = $widget->update( $expected, $instance );
    349         $this->assertSame( $result, $expected );
     349        $this->assertSame( $expected, $result );
    350350
    351351        // Should filter invalid rel text.
     
    368368        );
    369369        $result   = $widget->update( $expected, $instance );
    370         $this->assertSame( $result, $expected );
     370        $this->assertSame( $expected, $result );
    371371
    372372        // Should filter invalid  link target.
     
    384384        );
    385385        $result   = $widget->update( $expected, $instance );
    386         $this->assertSame( $result, $expected );
     386        $this->assertSame( $expected, $result );
    387387
    388388        // Should filter invalid image title.
  • trunk/tests/phpunit/tests/widgets/wpWidgetMediaVideo.php

    r52010 r52248  
    127127        );
    128128        $result   = $widget->update( $expected, $instance );
    129         $this->assertSame( $result, $expected );
     129        $this->assertSame( $expected, $result );
    130130
    131131        // Should filter invalid attachment ID.
     
    143143        );
    144144        $result   = $widget->update( $expected, $instance );
    145         $this->assertSame( $result, $expected );
     145        $this->assertSame( $expected, $result );
    146146
    147147        // Should filter invalid attachment url.
     
    160160        );
    161161        $result   = $widget->update( $expected, $instance );
    162         $this->assertSame( $result, $expected );
     162        $this->assertSame( $expected, $result );
    163163
    164164        // Should filter invalid loop setting.
     
    176176        );
    177177        $result   = $widget->update( $expected, $instance );
    178         $this->assertSame( $result, $expected );
     178        $this->assertSame( $expected, $result );
    179179
    180180        // Should filter invalid attachment title.
     
    192192        );
    193193        $result   = $widget->update( $expected, $instance );
    194         $this->assertSame( $result, $expected );
     194        $this->assertSame( $expected, $result );
    195195
    196196        // Should filter invalid preload setting.
Note: See TracChangeset for help on using the changeset viewer.