$order->get_id(), 'reason' => 'testing', 'amount' => 1, ) ); $this->assertNotWPError( $refund ); // Prime cache. $fetched_order = wc_get_orders( array( 'p' => $order->get_id() ) )[0]; $refund_cache_key = WC_Cache_Helper::get_cache_prefix( 'orders' ) . 'refunds' . $order->get_id(); $cached_refunds = wp_cache_get( $refund_cache_key, 'orders' ); $this->assertEquals( $cached_refunds[0]->get_id(), $fetched_order->get_refunds()[0]->get_id() ); $refund->delete( true ); // Cache should be cleared now. $cached_refunds = wp_cache_get( $refund_cache_key, 'orders' ); $this->assertEquals( false, $cached_refunds ); } }