1
0
mirror of synced 2025-01-31 07:11:42 +03:00
This commit is contained in:
Sergey 2018-12-07 13:02:37 +03:00
parent cc3867d275
commit eb169b9fc8
7 changed files with 203 additions and 10 deletions

View File

@ -1,3 +1,7 @@
## 2018-12-06 v3.3.6
* Исправлена активация модуля в маркетплейсе retailCRM при использовании api v4
* Расширена отправляемая конфигурация
## 2018-10-25 v3.3.5
* Добавлена активация модуля в маркетплейсе retailCRM

View File

@ -1 +1 @@
3.3.5
3.3.6

View File

@ -90,21 +90,31 @@ class WC_Retailcrm_Plugin {
*
* @return boolean
*/
public static function integration_module($api_client, $client_id, $active = true) {
public static function integration_module($api_client, $client_id, $api_version, $active = true) {
if (!$api_client) {
return false;
}
$configuration = array(
'clientId' => $client_id,
'code' => self::INTEGRATION_CODE . '-' . $client_id,
'integrationCode' => self::INTEGRATION_CODE,
'active' => $active,
'name' => 'WooCommerce',
'logo' => self::MARKETPLACE_LOGO
'logo' => self::MARKETPLACE_LOGO,
'code' => self::INTEGRATION_CODE . '-' . $client_id,
'active' => $active,
);
$response = $api_client->integrationModulesEdit($configuration);
if ($api_version == 'v4') {
$configuration['configurationUrl'] = get_site_url();
$response = $api_client->marketplaceSettingsEdit($configuration);
} else {
$configuration['integrationCode'] = self::INTEGRATION_CODE;
$configuration['baseUrl'] = get_site_url();
$configuration['clientId'] = $client_id;
$configuration['accountUrl'] = get_site_url();
$response = $api_client->integrationModulesEdit($configuration);
}
if (!$response) {
return false;

View File

@ -45,6 +45,9 @@ API-ключ должен быть для отдельного магазина
2. В появившихся списках справочников настройте соответствие способов доставки и оплаты, а так же статусов заказов. Отметьте галочку "Выгружать остатки", если хотите выгружать остатки из Retailcrm в магазин (подробнее смотрите в описании).
== Changelog ==
= 3.3.6 =
* Исправлена активация модуля в маркетплейсе retailCRM при использовании api v4
= 3.3.5 =
* Добавлена активация модуля в маркетплейсе retailCRM

View File

@ -1,6 +1,6 @@
<?php
/**
* Version: 3.3.5
* Version: 3.3.6
* WC requires at least: 3.0
* WC tested up to: 3.4.3
* Plugin Name: WooCommerce RetailCRM

View File

@ -15,7 +15,7 @@
*
*
* @link https://wordpress.org/plugins/woo-retailcrm/
* @version 3.3.5
* @version 3.3.6
*
* @package RetailCRM
*/

View File

@ -0,0 +1,176 @@
<?php
class WC_Retailcrm_Plugin_Test extends WC_Retailcrm_Test_Case_Helper
{
protected $apiMock;
protected $responseMock;
public function setUp()
{
$this->responseMock = $this->getMockBuilder('\WC_Retailcrm_Response_Helper')
->disableOriginalConstructor()
->setMethods(array(
'isSuccessful'
))
->getMock();
$this->apiMock = $this->getMockBuilder('\WC_Retailcrm_Proxy')
->disableOriginalConstructor()
->setMethods(array(
'marketplaceSettingsEdit'
))
->getMock();
parent::setUp();
}
/**
* @param $retailcrm
* @param $response
* @param $apiVersion
*
* @dataProvider dataProviderIntegrationModule
*/
public function test_integration_module($retailcrm,$response, $apiVersion)
{
$client_id = uniqid();
$result = WC_Retailcrm_Plugin::integration_module($retailcrm, $client_id, $apiVersion);
if (!$retailcrm || $response['success'] == false) {
$this->assertEquals(false, $result);
} else {
$this->assertEquals(true, $result);
}
}
private function getResponseData()
{
return array(
'v4' => array(
"true" => array(
"success" => true
),
"false" => array(
"success" => false
)
),
'v5' => array(
"true" => array(
"success" => true
),
"false" => array(
"success" => false,
"errorMsg" => "Forbidden"
)
)
);
}
public function dataProviderIntegrationModule()
{
$this->setUp();
return array(
array(
'retailcrm' => $this->getApiMock(
'v4',
$this->getResponseData['v4']['true']
),
'response' => $this->getResponseData['v4']['true'],
'apiVersion' => 'v4'
),
array(
'retailcrm' => false,
'response' => $this->getResponseData['v4']['true'],
'apiVersion' => 'v4'
),
array(
'retailcrm' => $this->getApiMock(
'v4',
$this->getResponseData['v4']['false']
),
'response' => $this->getResponseData['v4']['false'],
'apiVersion' => 'v4'
),
array(
'retailcrm' => false,
'response' => $this->getResponseData['v4']['false'],
'apiVersion' => 'v4'
),
array(
'retailcrm' => $this->getApiMock(
'v5',
$this->getResponseData['v5']['true']
),
'response' => $this->getResponseData['v5']['true'],
'apiVersion' => 'v5'
),
array(
'retailcrm' => false,
'response' => $this->getResponseData['v5']['true'],
'apiVersion' => 'v5'
),
array(
'retailcrm' => $this->getApiMock(
'v5',
$this->getResponseData['v5']['false']
),
'response' => $this->getResponseData['v5']['false'],
'apiVersion' => 'v5'
),
array(
'retailcrm' => false,
'response' => $this->getResponseData['v5']['false'],
'apiVersion' => 'v5'
)
);
}
private function getApiMock($apiVersion, $response)
{
$responseMock = $this->getMockBuilder('\WC_Retailcrm_Response_Helper')
->disableOriginalConstructor()
->setMethods(array(
'isSuccessful'
))
->getMock();
if ($response['success'] == true) {
$responseMock->expects($this->any())
->method('isSuccessful')
->willReturn(true);
} elseif ($response['success'] == false) {
$responseMock->expects($this->any())
->method('isSuccessful')
->willReturn(false);
}
$responseMock->setResponse($response);
if ($apiVersion == 'v4') {
$apiMock = $this->getMockBuilder('\WC_Retailcrm_Proxy')
->disableOriginalConstructor()
->setMethods(array(
'marketplaceSettingsEdit'
))
->getMock();
$apiMock->expects($this->any())
->method('marketplaceSettingsEdit')
->willReturn($responseMock);
} else {
$apiMock = $this->getMockBuilder('\WC_Retailcrm_Proxy')
->disableOriginalConstructor()
->setMethods(array(
'integrationModulesEdit'
))
->getMock();
$apiMock->expects($this->any())
->method('integrationModulesEdit')
->willReturn($responseMock);
}
return $apiMock;
}
}