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/multisite/site.php

    r48937 r48939  
    15751575            $result = wp_normalize_site_data( $data );
    15761576
    1577             $this->assertEqualSetsWithIndex( $expected, $result );
     1577            $this->assertSameSetsWithIndex( $expected, $result );
    15781578        }
    15791579
     
    16581658                $this->assertEmpty( $result->errors );
    16591659            } else {
    1660                 $this->assertEqualSets( $expected_errors, array_keys( $result->errors ) );
     1660                $this->assertSameSets( $expected_errors, array_keys( $result->errors ) );
    16611661            }
    16621662        }
     
    19561956
    19571957            // Check both insert and update results.
    1958             $this->assertEqualSetsWithIndex( $insert_expected, $insert_result );
    1959             $this->assertEqualSetsWithIndex( $update_expected, $update_result );
     1958            $this->assertSameSetsWithIndex( $insert_expected, $insert_result );
     1959            $this->assertSameSetsWithIndex( $update_expected, $update_result );
    19601960        }
    19611961
     
    21882188
    21892189            $this->assertTrue( $result );
    2190             $this->assertEqualSets(
     2190            $this->assertSameSets(
    21912191                array(
    21922192                    'administrator',
     
    23522352            $this->wp_initialize_site_args = null;
    23532353
    2354             $this->assertEqualSetsWithIndex( $args, $passed_args );
     2354            $this->assertSameSetsWithIndex( $args, $passed_args );
    23552355        }
    23562356
Note: See TracChangeset for help on using the changeset viewer.