Make WordPress Core


Ignore:
Timestamp:
09/29/2023 03:22:12 PM (2 years ago)
Author:
jorbin
Message:

Tests: Reduce usage of assertEquals

Replaces assertSame with assertCount in a number of tests.

Props ayeshrajans, jorbin.
See #58956.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/meta.php

    r56695 r56746  
    152152
    153153        // Test EXISTS and NOT EXISTS together, no users should be found.
    154         $this->assertSame(
     154        $this->assertCount(
    155155            0,
    156             count(
    157                 get_users(
    158                     array(
    159                         'meta_query' => array(
    160                             array(
    161                                 'key'     => 'meta_key',
    162                                 'compare' => 'NOT EXISTS',
    163                             ),
    164                             array(
    165                                 'key'     => 'delete_meta_key',
    166                                 'compare' => 'EXISTS',
    167                             ),
     156            get_users(
     157                array(
     158                    'meta_query' => array(
     159                        array(
     160                            'key'     => 'meta_key',
     161                            'compare' => 'NOT EXISTS',
    168162                        ),
    169                     )
     163                        array(
     164                            'key'     => 'delete_meta_key',
     165                            'compare' => 'EXISTS',
     166                        ),
     167                    ),
    170168                )
    171169            )
    172170        );
    173171
    174         $this->assertSame(
     172        $this->assertCount(
    175173            2,
    176             count(
    177                 get_users(
    178                     array(
    179                         'meta_query' => array(
    180                             array(
    181                                 'key'     => 'non_existing_meta',
    182                                 'compare' => 'NOT EXISTS',
    183                             ),
     174            get_users(
     175                array(
     176                    'meta_query' => array(
     177                        array(
     178                            'key'     => 'non_existing_meta',
     179                            'compare' => 'NOT EXISTS',
    184180                        ),
    185                     )
     181                    ),
    186182                )
    187183            )
     
    190186        delete_metadata( 'user', $this->author->ID, 'meta_key' );
    191187
    192         $this->assertSame(
     188        $this->assertCount(
    193189            2,
    194             count(
    195                 get_users(
    196                     array(
    197                         'meta_query' => array(
    198                             array(
    199                                 'key'     => 'meta_key',
    200                                 'compare' => 'NOT EXISTS',
    201                             ),
     190            get_users(
     191                array(
     192                    'meta_query' => array(
     193                        array(
     194                            'key'     => 'meta_key',
     195                            'compare' => 'NOT EXISTS',
    202196                        ),
    203                     )
     197                    ),
    204198                )
    205199            )
Note: See TracChangeset for help on using the changeset viewer.