Small fix in WC_Tests_Admin_Post_Types::bulk_and_quick_edit_stock_status_for_variable_product.

At some point the 'change_stock' key is assumed to be present
in the request data, but it might not. Fixed to test for existence
before using the value.
This commit is contained in:
Nestor Soriano 2020-04-15 13:00:52 +02:00
parent e05aa8a03a
commit 4531af3382
2 changed files with 1 additions and 2 deletions

View File

@ -559,7 +559,7 @@ class WC_Admin_Post_Types {
$product->set_backorders( $backorders );
if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) {
$change_stock = absint( $request_data['change_stock'] );
$change_stock = empty( $request_data['change_stock'] ) ? 0 : absint( $request_data['change_stock'] );
switch ( $change_stock ) {
case 2:
wc_update_product_stock( $product, $stock_amount, 'increase', true );

View File

@ -51,7 +51,6 @@ class WC_Tests_Admin_Post_Types extends WC_Unit_Test_Case {
$request_data = array(
"woocommerce_{$edit_type}" => '1',
'change_stock' => '',
'_stock_status' => $change_stock_request_value,
'woocommerce_quick_edit_nonce' => wp_create_nonce( 'woocommerce_quick_edit_nonce' ),
);