Replace array_merge_recursive in MockableLegacyProxy with custom code

test_static_mocks_can_be_used_via_injected_legacy_proxy_and_woocommerce_object
was failing in PHP 7.0, this replacement fixes it.
Suspected cause: https://bugs.php.net/bug.php?id=76505
This commit is contained in:
Nestor Soriano 2020-07-24 14:51:37 +02:00
parent 8f596bd25a
commit c2e28b2b05
1 changed files with 10 additions and 1 deletions

View File

@ -86,7 +86,16 @@ class MockableLegacyProxy extends \Automattic\WooCommerce\Proxies\LegacyProxy {
}
}
$this->mocked_statics = array_merge_recursive( $this->mocked_statics, $mocks );
// TODO: replace the following with just "$this->mocked_statics = array_merge_recursive( $this->mocked_statics, $mocks )" once the minimum PHP version is bumped to 7.1 or newer (see https://bugs.php.net/bug.php?id=76505).
$class_names = array_keys( $mocks );
foreach ( $class_names as $class_name ) {
if ( array_key_exists( $class_name, $this->mocked_statics ) ) {
$this->mocked_statics[ $class_name ] = array_merge( $this->mocked_statics[ $class_name ], $mocks[ $class_name ] );
} else {
$this->mocked_statics[ $class_name ] = $mocks[ $class_name ];
}
}
}
/**