Добавлена передача поля link при выгрузке брошенных корзин (#352)
This commit is contained in:
parent
1ab3dacaf7
commit
3e3e37b297
@ -1,3 +1,6 @@
|
||||
## 2024-07-15 v.6.5.21
|
||||
- Добавлена передача поля link при выгрузке брошенных корзин
|
||||
|
||||
## 2024-06-20 v.6.5.20
|
||||
- Рефакторинг настроек модуля
|
||||
|
||||
|
@ -105,6 +105,7 @@ class RetailCrmCart
|
||||
$date => date(self::$dateFormat),
|
||||
'droppedAt' => date(self::$dateFormat),
|
||||
'items' => $items,
|
||||
'link' => static::generateCartLink(),
|
||||
],
|
||||
$site
|
||||
);
|
||||
@ -139,4 +140,13 @@ class RetailCrmCart
|
||||
|
||||
return $arBasket;
|
||||
}
|
||||
|
||||
public static function generateCartLink()
|
||||
{
|
||||
return sprintf(
|
||||
'%s://%s/personal/cart',
|
||||
!empty($_SERVER['HTTPS']) ? 'https' : 'http',
|
||||
$_SERVER['HTTP_HOST']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use Bitrix\Main\Context\Culture;
|
||||
use Bitrix\Main\Engine\CurrentUser;
|
||||
use Intaro\RetailCrm\Component\Constants;
|
||||
use Intaro\RetailCrm\Component\ServiceLocator;
|
||||
use Intaro\RetailCrm\Repository\UserRepository;
|
||||
@ -113,8 +114,6 @@ class RetailCrmEvent
|
||||
public static function orderDelete($event)
|
||||
{
|
||||
$GLOBALS['RETAILCRM_ORDER_DELETE'] = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,7 +129,7 @@ class RetailCrmEvent
|
||||
return;
|
||||
}
|
||||
|
||||
$id = \Bitrix\Main\Engine\CurrentUser::get()->getId();
|
||||
$id = CurrentUser::get()->getId();
|
||||
|
||||
if ($id) {
|
||||
$arBasket = RetailCrmCart::getBasketArray($event);
|
||||
|
@ -1 +1 @@
|
||||
- Рефакторинг настроек модуля
|
||||
- Добавлена передача поля link при выгрузке брошенных корзин
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$arModuleVersion = [
|
||||
'VERSION' => '6.5.20',
|
||||
'VERSION_DATE' => '2024-06-20 17:40:00'
|
||||
'VERSION' => '6.5.21',
|
||||
'VERSION_DATE' => '2024-07-15 17:00:00'
|
||||
];
|
||||
|
110
tests/classes/general/cart/RetailCrmCartTest.php
Normal file
110
tests/classes/general/cart/RetailCrmCartTest.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace classes\general\cart;
|
||||
|
||||
use DateTime;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use RCrmActions;
|
||||
use RetailCrmCart;
|
||||
|
||||
class RetailCrmCartTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testSetBasket(): void
|
||||
{
|
||||
$arBasket = $this->getBasket();
|
||||
$crmBasket = $this->getCrmCart();
|
||||
$actionsMock = Mockery::mock('alias:' . RCrmActions::class);
|
||||
|
||||
$actionsMock->shouldReceive('apiMethod')->withAnyArgs()->andReturn($crmBasket, ['success' => true]);
|
||||
|
||||
$result = RetailCrmCart::handlerCart($arBasket);
|
||||
|
||||
self::assertTrue($result['success']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testClearBasket(): void
|
||||
{
|
||||
$arBasket = ['LID' => 's1', 'USER_ID' => '1'];
|
||||
$crmBasket = $this->getCrmCart();
|
||||
$actionsMock = Mockery::mock('alias:' . RCrmActions::class);
|
||||
|
||||
$actionsMock->shouldReceive('apiMethod')->withAnyArgs()->andReturn($crmBasket, ['success' => true]);
|
||||
|
||||
$result = RetailCrmCart::handlerCart($arBasket);
|
||||
|
||||
self::assertTrue($result['success']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testIgnoreChangeBasket()
|
||||
{
|
||||
$arBasket = ['LID' => 's1', 'USER_ID' => '1'];
|
||||
$crmBasket = [];
|
||||
$actionsMock = Mockery::mock('alias:' . RCrmActions::class);
|
||||
|
||||
$actionsMock->shouldReceive('apiMethod')->withAnyArgs()->andReturn($crmBasket);
|
||||
|
||||
$result = RetailCrmCart::handlerCart($arBasket);
|
||||
|
||||
self::assertNull($result);
|
||||
}
|
||||
|
||||
public function testGenerateCartLink()
|
||||
{
|
||||
$cartLink = RetailCrmCart::generateCartLink();
|
||||
|
||||
self::assertNotNull($cartLink);
|
||||
self::assertContains('/personal/cart', $cartLink);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getBasket(): array
|
||||
{
|
||||
return [
|
||||
'LID' => 's1',
|
||||
'USER_ID' => '1',
|
||||
'BASKET' => [
|
||||
[
|
||||
'QUANTITY' => 2,
|
||||
'PRICE' => 100,
|
||||
'DATE_INSERT' => new DateTime('now'),
|
||||
'DATE_UPDATE' => new DateTime('now'),
|
||||
'PRODUCT_ID' => '10'
|
||||
],
|
||||
[
|
||||
'QUANTITY' => 1,
|
||||
'PRICE' => 300,
|
||||
'DATE_INSERT' => new DateTime('now'),
|
||||
'DATE_UPDATE' => new DateTime('now'),
|
||||
'PRODUCT_ID' => '2'
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCrmCart(): array
|
||||
{
|
||||
return [
|
||||
'cart' => [
|
||||
'items' => 'items'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
@ -271,67 +271,12 @@ class RetailCrmEventTest extends PHPUnit\Framework\TestCase
|
||||
'ORDER_PROP' => []
|
||||
];
|
||||
|
||||
$result = RetailCrmEvent::OnUpdateOrder(1, $arFields);
|
||||
RetailCrmEvent::OnUpdateOrder(1, $arFields);
|
||||
|
||||
$this->assertEquals(true, $GLOBALS['RETAILCRM_ORDER_OLD_EVENT']);
|
||||
|
||||
$this->assertEquals(true, $GLOBALS['ORDER_DELETE_USER_ADMIN']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testSetBasket(): void
|
||||
{
|
||||
$arBasket = $this->getBasket();
|
||||
$crmBasket = $this->getCrmCart();
|
||||
|
||||
$actionsMock = Mockery::mock('alias:' . RCrmActions::class);
|
||||
|
||||
$actionsMock->shouldReceive('apiMethod')->withAnyArgs()->andReturn($crmBasket, ['success' => true]);
|
||||
|
||||
$result = RetailCrmCart::handlerCart($arBasket);
|
||||
|
||||
self::assertTrue($result['success']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testClearBasket(): void
|
||||
{
|
||||
$arBasket = ['LID' => 's1', 'USER_ID' => '1'];
|
||||
$crmBasket = $this->getCrmCart();
|
||||
|
||||
$actionsMock = Mockery::mock('alias:' . RCrmActions::class);
|
||||
|
||||
$actionsMock->shouldReceive('apiMethod')->withAnyArgs()->andReturn($crmBasket, ['success' => true]);
|
||||
|
||||
$result = RetailCrmCart::handlerCart($arBasket);
|
||||
|
||||
self::assertTrue($result['success']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testIgnoreChangeBasket()
|
||||
{
|
||||
$arBasket = ['LID' => 's1', 'USER_ID' => '1'];
|
||||
$crmBasket = [];
|
||||
|
||||
$actionsMock = Mockery::mock('alias:' . RCrmActions::class);
|
||||
|
||||
$actionsMock->shouldReceive('apiMethod')->withAnyArgs()->andReturn($crmBasket);
|
||||
|
||||
$result = RetailCrmCart::handlerCart($arBasket);
|
||||
|
||||
self::assertNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@ -392,43 +337,4 @@ class RetailCrmEventTest extends PHPUnit\Framework\TestCase
|
||||
$GLOBALS['RETAILCRM_ORDER_OLD_EVENT'] = true;
|
||||
$GLOBALS['RETAILCRM_ORDER_DELETE'] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getBasket(): array
|
||||
{
|
||||
return [
|
||||
'LID' => 's1',
|
||||
'USER_ID' => '1',
|
||||
'BASKET' => [
|
||||
[
|
||||
'QUANTITY' => 2,
|
||||
'PRICE' => 100,
|
||||
'DATE_INSERT' => new DateTime('now'),
|
||||
'DATE_UPDATE' => new DateTime('now'),
|
||||
'PRODUCT_ID' => '10'
|
||||
],
|
||||
[
|
||||
'QUANTITY' => 1,
|
||||
'PRICE' => 300,
|
||||
'DATE_INSERT' => new DateTime('now'),
|
||||
'DATE_UPDATE' => new DateTime('now'),
|
||||
'PRODUCT_ID' => '2'
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCrmCart(): array
|
||||
{
|
||||
return [
|
||||
'cart' => [
|
||||
'items' => 'items'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user