From 37106577c6f3e9511e5f59bb59d7fdeeb9ab7602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB?= Date: Thu, 9 Apr 2020 13:24:52 +0300 Subject: [PATCH] possible fix for history --- .../order/class-wc-retailcrm-order-payment.php | 2 ++ tests/test-wc-retailcrm-history.php | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/include/order/class-wc-retailcrm-order-payment.php b/src/include/order/class-wc-retailcrm-order-payment.php index 7704f5c..a36a732 100644 --- a/src/include/order/class-wc-retailcrm-order-payment.php +++ b/src/include/order/class-wc-retailcrm-order-payment.php @@ -57,6 +57,8 @@ class WC_Retailcrm_Order_Payment extends WC_Retailcrm_Abstracts_Data && $this->settings['send_payment_amount'] === WC_Retailcrm_Base::YES ) { $data['amount'] = (double) $order->get_total(); + } else { + unset($data['amount']); } if (!$this->is_new) { diff --git a/tests/test-wc-retailcrm-history.php b/tests/test-wc-retailcrm-history.php index f28515b..4df2134 100644 --- a/tests/test-wc-retailcrm-history.php +++ b/tests/test-wc-retailcrm-history.php @@ -2,8 +2,13 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper { + /** @var WC_Retailcrm_Proxy */ protected $apiMock; + + /** @var WC_Retailcrm_Response_Helper */ protected $customersHistoryResponse; + + /** @var WC_Retailcrm_Response_Helper */ protected $ordersHistoryResponse; const STATUS_1 = 'status1'; @@ -44,6 +49,14 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper { $this->setOptions($api_version); + if (!add_option('retailcrm_orders_history_since_id', 0)) { + update_option('retailcrm_orders_history_since_id', 0); + } + + if (!add_option('retailcrm_customers_history_since_id', 0)) { + update_option('retailcrm_customers_history_since_id', 0); + } + $this->customersHistoryResponse->expects($this->any()) ->method('isSuccessful') ->willReturn(true); @@ -70,7 +83,7 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper $order_added = end($orders); if (!$order_added) { - $this->fail('$order_added is null'); + $this->fail('$order_added is null - no orders were added after receiving history'); } $order_added_items = $order_added->get_items();