Make WordPress Core


Ignore:
Timestamp:
08/07/2021 10:40:44 AM (3 years 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/widgets/wpWidgetMedia.php

    r51493 r51569  
    9696        $this->assertSame( $name, $widget->name );
    9797
    98         $this->assertArraySubset( $widget_options, $widget->widget_options );
    99         $this->assertArraySubset( $control_options, $widget->control_options );
     98        foreach ( $widget_options as $key => $value ) {
     99            $this->assertArrayHasKey( $key, $widget->widget_options );
     100            $this->assertSame( $value, $widget->widget_options[ $key ] );
     101        }
     102
     103        foreach ( $control_options as $key => $value ) {
     104            $this->assertArrayHasKey( $key, $widget->control_options );
     105            $this->assertSame( $value, $widget->control_options[ $key ] );
     106        }
    100107    }
    101108
Note: See TracChangeset for help on using the changeset viewer.