Skip to content
This repository was archived by the owner on Jun 15, 2022. It is now read-only.

Commit 765dc50

Browse files
committed
Add a test for the product line item searching within search_orders()
1 parent 613d6ca commit 765dc50

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

tests/test-data-store.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,19 @@ public function test_search_orders_only_checks_post_meta_if_specified() {
128128
);
129129
}
130130

131+
public function test_search_orders_checks_table_for_product_item_matches() {
132+
$product = $this->factory()->product->create_and_get();
133+
$order = $this->factory()->order->create_and_get();
134+
$order->add_product( $product );
135+
$order->save();
136+
137+
$this->assertEquals(
138+
array( $order->get_id() ),
139+
( new WC_Order_Data_Store_Custom_Table() )->search_orders( $product->get_name() ),
140+
'Order searches should extend to the names of product items.'
141+
);
142+
}
143+
131144
/**
132145
* @dataProvider order_type_provider()
133146
*/

tests/test-tools/class-wp-unittest-factory-for-product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function __construct( $factory = null ) {
1919
'post_title' => new WP_UnitTest_Generator_Sequence( 'Product name %s' ),
2020
'post_content' => new WP_UnitTest_Generator_Sequence( 'Product description %s' ),
2121
'post_excerpt' => new WP_UnitTest_Generator_Sequence( 'Product short description %s' ),
22-
'post_type' => 'post',
22+
'post_type' => 'product',
2323
);
2424
}
2525

0 commit comments

Comments
 (0)