Skip to content

Commit

Permalink
Test_WP_Widget_Media::test_constructor(): remove use of assertArraySu…
Browse files Browse the repository at this point in the history
…bset()

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

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

Refs:
* https://github.com/sebastianbergmann/phpunit/blob/8.0.6/ChangeLog-8.0.md#800---2019-02-01
* sebastianbergmann/phpunit#3494
  • Loading branch information
jrfnl committed Aug 16, 2020
1 parent 68434af commit 90310fe
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/phpunit/tests/widgets/media-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,14 @@ function test_constructor() {
$this->assertEquals( $id_base, $widget->id_base );
$this->assertEquals( $name, $widget->name );

// Method assertArraySubset doesn't exist in phpunit versions compatible with PHP 5.2.
if ( method_exists( $this, 'assertArraySubset' ) ) {
$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 ] );
}
}

Expand Down

0 comments on commit 90310fe

Please sign in to comment.