WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/07/2021 10:40:44 AM (4 months ago)
Author:
SergeyBiryukov
Message:

Tests: Remove use of assertArraySubset() in Test_WP_Widget_Media::test_constructor().

The assertArraySubset() method has been deprecated in PHPUnit 8 and removed in PHPUnit 9.

This replaces the assertions with looping through the array and testing both the key and the value individually.

References:

Note: There is a polyfill package available for the removed assertion: dms/phpunit-arraysubset-asserts, but as the assertion was only used in this one test method, adding this seems redundant.

Follow-up to [51559-51568].

Props jrf.
See #46149.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/customize/nav-menus.php

    r51568 r51569  
    11451145        $this->assertTrue( (bool) preg_match( '/data-customize-partial-placement-context="(.+?)"/', $result, $matches ) );
    11461146        $context = json_decode( html_entity_decode( $matches[1] ), true );
    1147         $this->assertSame( $original_args, wp_array_slice_assoc( $context, array_keys( $original_args ) ) ); // Because assertArraySubset is not available in PHP 5.2.
     1147
     1148        foreach ( $original_args as $key => $value ) {
     1149            $this->assertArrayHasKey( $key, $context );
     1150            $this->assertSame( $value, $context[ $key ] );
     1151        }
     1152
    11481153        $this->assertTrue( $context['can_partial_refresh'] );
    11491154    }
Note: See TracChangeset for help on using the changeset viewer.