Make WordPress Core


Ignore:
Timestamp:
09/04/2020 07:01:00 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: Introduce assertSameSets() and assertSameSetsWithIndex(), and use them where appropriate.

This ensures that not only the array values being compared are equal, but also that their type is the same.

These new methods replace most of the existing instances of assertEqualSets() and assertEqualSetsWithIndex().

Going forward, stricter type checking by using assertSameSets() or assertSameSetsWithIndex() should generally be preferred, to make the tests more reliable.

Follow-up to [48937].

See #38266.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ajax/UpdatePlugin.php

    r48445 r48939  
    4242        );
    4343
    44         $this->assertEqualSets( $expected, $response );
     44        $this->assertSameSets( $expected, $response );
    4545    }
    4646
     
    6868        );
    6969
    70         $this->assertEqualSets( $expected, $response );
     70        $this->assertSameSets( $expected, $response );
    7171    }
    7272
     
    9191                'update'       => 'plugin',
    9292                'slug'         => 'foo',
    93                 'errorMessage' => 'Sorry, you are not allowed to update plugins for this site.',
    9493                'oldVersion'   => '',
    9594                'newVersion'   => '',
     95                'errorMessage' => 'Sorry, you are not allowed to update plugins for this site.',
    9696            ),
    9797        );
    9898
    99         $this->assertEqualSets( $expected, $response );
     99        $this->assertSameSets( $expected, $response );
    100100    }
    101101
     
    122122                'update'       => 'plugin',
    123123                'slug'         => 'foo',
    124                 'errorMessage' => 'Sorry, you are not allowed to update plugins for this site.',
    125124                'oldVersion'   => '',
    126125                'newVersion'   => '',
     126                'errorMessage' => 'Sorry, you are not allowed to update plugins for this site.',
    127127            ),
    128128        );
    129129
    130         $this->assertEqualSets( $expected, $response );
     130        $this->assertSameSets( $expected, $response );
    131131    }
    132132
     
    156156                'update'       => 'plugin',
    157157                'slug'         => 'hello-dolly',
     158                'oldVersion'   => 'Version 1.7.2',
     159                'newVersion'   => '',
    158160                'plugin'       => 'hello.php',
    159161                'pluginName'   => 'Hello Dolly',
     162                'debug'        => array( 'The plugin is at the latest version.' ),
    160163                'errorMessage' => 'The plugin is at the latest version.',
    161                 'oldVersion'   => 'Version 1.7.2',
    162                 'newVersion'   => '',
    163                 'debug'        => array( 'The plugin is at the latest version.' ),
    164164            ),
    165165        );
    166166
    167         $this->assertEqualSets( $expected, $response );
     167        $this->assertSameSets( $expected, $response );
    168168    }
    169169}
Note: See TracChangeset for help on using the changeset viewer.