diff --git a/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php b/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php index 5b750462..09639809 100644 --- a/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php +++ b/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php @@ -623,7 +623,17 @@ class RetailcrmConfigProvider { return COption::GetOptionString("main", "new_user_phone_required") === 'Y'; } - + + /** + * Return integration_delivery option + * + * @return mixed + */ + public static function getCrmIntegrationDelivery() + { + return static::getUnserializedOption(RetailcrmConstants::CRM_INTEGRATION_DELIVERY); + } + /** * Wraps Bitrix COption::GetOptionString(...) * diff --git a/intaro.retailcrm/classes/general/services/RetailCrmService.php b/intaro.retailcrm/classes/general/services/RetailCrmService.php index 4820f9a7..c05715fd 100644 --- a/intaro.retailcrm/classes/general/services/RetailCrmService.php +++ b/intaro.retailcrm/classes/general/services/RetailCrmService.php @@ -1,39 +1,77 @@ '5958C', - 'externalId' => '8', - 'createdAt' => '2020-06-22 16:47:49', - 'customer' => array ( - 'externalId' => '3', - ), - 'orderType' => 'eshop-individual', - 'status' => 'prepayed', - 'delivery' => array ( - 'cost' => '0', - 'address' => array ( - 'text' => 'ул. Первомайская 41', - ), - 'code' => 'boxberry', - ), - 'contragent' => array ( - 'contragentType' => 'individual', - ), - 'discountManualAmount' => '0', - 'discountManualPercent' => '0', - 'items' => array ( - array ( - 'externalIds' => array ( - array ( - 'code' => 'bitrix', - 'value' => '0_88', - ), - ), - 'quantity' => '1', - 'offer' => array ( - 'externalId' => '88', - 'xmlId' => '248', - ), - 'productName' => 'Agustí Torelló Mata GR Barrica 2011', - 'id' => '9072', - 'discountManualPercent' => '0', - 'discountManualAmount' => '0', - 'initialPrice' => '21.25', - ), - ), - ); - + private $paramsExample = [ + 'delivery' => [ + 'code' => 'boxberry', + 'cost' => 'test', + 'address' => 'test', + 'data' => 'test', + ], + 'weight' => 'test', + 'firstName' => 'test', + 'lastName' => 'test', + 'phone' => 'test', + 'paymentType' => 'test', + 'shipmentStore' => 'test', + ]; + public function testOnUnsetIntegrationDeliveryFields() { - $newParams = RetailCrmService::unsetIntegrationDeliveryFields($this->paramsExample); - $expectedArray = $this->paramsExample; - unset($expectedArray['firstName']); - unset($expectedArray['lastName']); - unset($expectedArray['delivery']['address']); - unset($expectedArray['delivery']['cost']); - + $value = serialize(['boxberry' => 'test']); + COption::SetOptionString(RetailcrmConstants::MODULE_ID, RetailcrmConstants::CRM_INTEGRATION_DELIVERY, $value); + $newParams = RetailCrmService::unsetIntegrationDeliveryFields($this->paramsExample); + $expectedArray = [ + 'delivery' => [ + 'code' => 'boxberry', + ], + ]; + $this->assertEquals($newParams, $expectedArray); } }