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:
Paul Kilmurray 2017-05-04 18:47:43 +09:00 committed by GitHub
parent abfedafd46
commit b5f182e14d
1 changed files with 23 additions and 0 deletions

View File

@ -272,6 +272,29 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
$object->save();
$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