mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
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: * https://github.com/sebastianbergmann/phpunit/blob/8.0.6/ChangeLog-8.0.md#800---2019-02-01 * https://github.com/sebastianbergmann/phpunit/issues/3494 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. git-svn-id: https://develop.svn.wordpress.org/trunk@51569 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ddb409edca
commit
22060f3b06
@ -1144,7 +1144,12 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
$this->assertStringContainsString( ' data-customize-partial-type="nav_menu_instance"', $result );
|
||||
$this->assertTrue( (bool) preg_match( '/data-customize-partial-placement-context="(.+?)"/', $result, $matches ) );
|
||||
$context = json_decode( html_entity_decode( $matches[1] ), true );
|
||||
$this->assertSame( $original_args, wp_array_slice_assoc( $context, array_keys( $original_args ) ) ); // Because assertArraySubset is not available in PHP 5.2.
|
||||
|
||||
foreach ( $original_args as $key => $value ) {
|
||||
$this->assertArrayHasKey( $key, $context );
|
||||
$this->assertSame( $value, $context[ $key ] );
|
||||
}
|
||||
|
||||
$this->assertTrue( $context['can_partial_refresh'] );
|
||||
}
|
||||
|
||||
|
||||
@ -95,8 +95,15 @@ class Tests_Widgets_wpWidgetMedia extends WP_UnitTestCase {
|
||||
$this->assertSame( $id_base, $widget->id_base );
|
||||
$this->assertSame( $name, $widget->name );
|
||||
|
||||
$this->assertArraySubset( $widget_options, $widget->widget_options );
|
||||
$this->assertArraySubset( $control_options, $widget->control_options );
|
||||
foreach ( $widget_options as $key => $value ) {
|
||||
$this->assertArrayHasKey( $key, $widget->widget_options );
|
||||
$this->assertSame( $value, $widget->widget_options[ $key ] );
|
||||
}
|
||||
|
||||
foreach ( $control_options as $key => $value ) {
|
||||
$this->assertArrayHasKey( $key, $widget->control_options );
|
||||
$this->assertSame( $value, $widget->control_options[ $key ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user