Fix flaky orphaned refund test (#49741)

Make sure the `date_paid` -> `date` -> order is deterministic.

Fixes #49630

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Tomek Wytrębowicz 2024-07-23 21:44:23 +02:00 committed by GitHub
parent 4ae9dee2e5
commit 8fb0953204
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Fix flaky orphaned refund test

View File

@ -93,8 +93,6 @@ class WC_Admin_Tests_API_Reports_Orders extends WC_REST_Unit_Test_Case {
}
public function test_get_reports_with_orphaned_refund() {
$this->markTestSkipped( 'Flaky: see https://github.com/woocommerce/woocommerce/issues/49630' );
wp_set_current_user( $this->user );
WC_Helper_Reports::reset_stats_dbs();
@ -107,6 +105,8 @@ class WC_Admin_Tests_API_Reports_Orders extends WC_REST_Unit_Test_Case {
$order = WC_Helper_Order::create_order( 1, $product );
$order->set_status( 'completed' );
$order->set_total( 100 ); // $25 x 4.
// Make sure the order is paid at least a minute ago to avoid issues with the same timestamp - undeterministic order.
$order->set_date_paid( $order->get_date_paid()->modify( '-1 minute' ) );
$order->save();
$refund = wc_create_refund(
@ -134,8 +134,8 @@ class WC_Admin_Tests_API_Reports_Orders extends WC_REST_Unit_Test_Case {
$this->assertEquals( 200, $response->get_status() );
$this->assertEquals( 2, count( $reports ) );
$order_report = $reports[0];
$refund_report = $reports[1];
$refund_report = $reports[0];
$order_report = $reports[1];
$this->assertEquals( $order->get_id(), $order_report['order_id'] );
$this->assertEquals( $refund->get_id(), $refund_report['order_id'] );