Fix failing tests and array_merge error
This commit is contained in:
parent
5888ef5b93
commit
173c09dd04
|
@ -453,7 +453,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
if ( ! empty( $items[ $batch_type ] ) ) {
|
||||
$injected_items = array();
|
||||
foreach ( $items[ $batch_type ] as $item ) {
|
||||
$injected_items[] = array_merge( array( 'product_id' => $product_id ), $item );
|
||||
$injected_items[] = is_array( $item ) ? array_merge( array( 'product_id' => $product_id ), $item ) : $item;
|
||||
}
|
||||
$body_params[ $batch_type ] = $injected_items;
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
|
|||
if ( ! empty( $items[ $batch_type ] ) ) {
|
||||
$injected_items = array();
|
||||
foreach ( $items[ $batch_type ] as $item ) {
|
||||
$injected_items[] = array_merge( array( 'product_id' => $product_id ), $item );
|
||||
$injected_items[] = is_array( $item ) ? array_merge( array( 'product_id' => $product_id ), $item ) : $item;
|
||||
}
|
||||
$body_params[ $batch_type ] = $injected_items;
|
||||
}
|
||||
|
|
|
@ -383,8 +383,8 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
|
||||
$this->assertEquals( 'Updated review.', $data['update'][0]['review'] );
|
||||
$this->assertEquals( 'New review.', $data['create'][0]['review'] );
|
||||
$this->assertEquals( $review_2_id, $data['delete'][0] );
|
||||
$this->assertEquals( $review_3_id, $data['delete'][1] );
|
||||
$this->assertEquals( $review_2_id, $data['delete'][0]['id'] );
|
||||
$this->assertEquals( $review_3_id, $data['delete'][1]['id'] );
|
||||
|
||||
$request = new WP_REST_Request( 'GET', '/wc/v1/products/' . $product->get_id() . '/reviews' );
|
||||
$response = $this->server->dispatch( $request );
|
||||
|
|
|
@ -321,7 +321,7 @@ class Product_Variations_API extends WC_REST_Unit_Test_Case {
|
|||
$this->assertContains( 'Updated description.', $data['update'][0]['description'] );
|
||||
$this->assertEquals( 'DUMMY SKU VARIABLE MEDIUM', $data['create'][0]['sku'] );
|
||||
$this->assertEquals( 'medium', $data['create'][0]['attributes'][0]['option'] );
|
||||
$this->assertEquals( $children[1], $data['delete'][0] );
|
||||
$this->assertEquals( $children[1], $data['delete'][0]['id'] );
|
||||
|
||||
$request = new WP_REST_Request( 'GET', '/wc/v1/products/' . $product->get_id() . '/variations' );
|
||||
$response = $this->server->dispatch( $request );
|
||||
|
|
Loading…
Reference in New Issue