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/theme.php

    r48937 r48939  
    430430            'show_in_rest' => false,
    431431        );
    432         $this->assertEqualSets( $expected, get_registered_theme_feature( 'test-feature' ) );
     432        $this->assertSameSets( $expected, get_registered_theme_feature( 'test-feature' ) );
    433433    }
    434434
     
    467467        $expected = array(
    468468            'schema'           => array(
     469                'description' => '',
    469470                'type'        => 'boolean',
    470                 'description' => '',
    471471                'default'     => false,
    472472            ),
     
    476476        $actual   = get_registered_theme_feature( 'test-feature' )['show_in_rest'];
    477477
    478         $this->assertEqualSets( $expected, $actual );
     478        $this->assertSameSets( $expected, $actual );
    479479    }
    480480
     
    510510        $actual   = get_registered_theme_feature( 'test-feature' )['show_in_rest']['schema'];
    511511
    512         $this->assertEqualSets( $expected, $actual );
     512        $this->assertSameSets( $expected, $actual );
    513513    }
    514514
     
    588588        $actual   = get_registered_theme_feature( 'test-feature' )['show_in_rest']['schema']['additionalProperties'];
    589589
    590         $this->assertEqualSets( $expected, $actual );
     590        $this->assertSameSets( $expected, $actual );
    591591    }
    592592
Note: See TracChangeset for help on using the changeset viewer.