Problem in WC_Abstract_Order->get_items()
This test will fail. If the order is created with different item types, eg: *line_item* and *fee*, they will both be given the key `new:0`. Items with duplicate keys are not combined in the `get_items` function ([line 703](https://github.com/woocommerce/woocommerce/blob/master/includes/abstracts/abstract-wc-order.php#L703)).
This commit is contained in:
parent
abfedafd46
commit
b5f182e14d
|
@ -272,6 +272,29 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
||||||
$object->save();
|
$object->save();
|
||||||
$this->assertCount( 2, $object->get_items() );
|
$this->assertCount( 2, $object->get_items() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test: get_different_items
|
||||||
|
*/
|
||||||
|
function test_get_different_items() {
|
||||||
|
$object = new WC_Order();
|
||||||
|
$item_1 = new WC_Order_Item_Product();
|
||||||
|
$item_1->set_props( array(
|
||||||
|
'product' => WC_Helper_Product::create_simple_product(),
|
||||||
|
'quantity' => 4,
|
||||||
|
) );
|
||||||
|
$item_2 = new WC_Order_Item_Fee();
|
||||||
|
$item_2->set_props( array(
|
||||||
|
'name' => 'Some Fee',
|
||||||
|
'tax_status' => 'taxable',
|
||||||
|
'total' => '100',
|
||||||
|
'tax_class' => '',
|
||||||
|
) );
|
||||||
|
$object->add_item( $item_1 );
|
||||||
|
$object->add_item( $item_2 );
|
||||||
|
$object->save();
|
||||||
|
$this->assertCount( 2, $object->get_items( array( 'line_item', 'fee' ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test: get_fees
|
* Test: get_fees
|
||||||
|
|
Loading…
Reference in New Issue