2020-07-22 15:11:27 +03:00
|
|
|
<?php
|
|
|
|
|
2023-05-29 14:13:05 +03:00
|
|
|
use Tests\Intaro\RetailCrm\DataService;
|
|
|
|
|
2020-07-22 15:11:27 +03:00
|
|
|
/**
|
|
|
|
* Class RetailCrmServiceTest
|
|
|
|
*/
|
|
|
|
class RetailCrmServiceTest extends PHPUnit\Framework\TestCase
|
|
|
|
{
|
|
|
|
public function testOnUnsetIntegrationDeliveryFields()
|
|
|
|
{
|
2020-09-28 13:02:03 +03:00
|
|
|
$value = serialize(['boxberry' => 'test']);
|
|
|
|
COption::SetOptionString(RetailcrmConstants::MODULE_ID, RetailcrmConstants::CRM_INTEGRATION_DELIVERY, $value);
|
2023-05-29 14:13:05 +03:00
|
|
|
$newParams = RetailCrmService::unsetIntegrationDeliveryFields(DataService::deliveryDataForValidation());
|
2020-09-28 13:02:03 +03:00
|
|
|
$expectedArray = [
|
|
|
|
'delivery' => [
|
|
|
|
'code' => 'boxberry',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
2020-07-22 15:11:27 +03:00
|
|
|
$this->assertEquals($newParams, $expectedArray);
|
|
|
|
}
|
2022-07-20 12:46:32 +03:00
|
|
|
|
2023-05-29 14:13:05 +03:00
|
|
|
public function testOnUnsetIntegrationDeliveryFieldsWithCourier()
|
|
|
|
{
|
|
|
|
$value = serialize(['test' => 'courier']);
|
|
|
|
COption::SetOptionString(RetailcrmConstants::MODULE_ID, RetailcrmConstants::CRM_INTEGRATION_DELIVERY, $value);
|
|
|
|
$result = RetailCrmService::unsetIntegrationDeliveryFields(DataService::deliveryDataCourier());
|
|
|
|
|
|
|
|
$this->assertEquals(DataService::deliveryDataCourier(), $result);
|
|
|
|
}
|
|
|
|
|
2022-07-20 12:46:32 +03:00
|
|
|
/**
|
|
|
|
* @param array $data
|
|
|
|
* @param array $expected
|
|
|
|
* @dataProvider selectIntegrationDeliveriesProvider
|
|
|
|
*/
|
|
|
|
public function testSelectIntegrationDeliveries(array $data, array $expected)
|
|
|
|
{
|
|
|
|
$this->assertEquals($expected, RetailCrmService::selectIntegrationDeliveries($data));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $data
|
|
|
|
* @param array $expected
|
|
|
|
* @dataProvider selectIntegrationPaymentsProvider
|
|
|
|
*/
|
|
|
|
public function testSelectIntegrationPayments(array $data, array $expected)
|
|
|
|
{
|
|
|
|
$this->assertEquals($expected, RetailCrmService::selectIntegrationPayments($data));
|
|
|
|
}
|
|
|
|
|
2023-06-07 14:39:34 +03:00
|
|
|
public function testGetAvailableTypes(): void
|
|
|
|
{
|
|
|
|
$data = DataService::availableSitesAndTypesData();
|
|
|
|
$sites = $data['sites'];
|
|
|
|
$types = $data['types'];
|
|
|
|
|
|
|
|
$result = RetailCrmService::getAvailableTypes($sites, $types);
|
|
|
|
|
|
|
|
$this->assertCount(3, $result);
|
2024-01-24 15:01:13 +03:00
|
|
|
$this->assertEquals('test1', $result['test1']['code']);
|
|
|
|
$this->assertEquals('test4', $result['test4']['code']);
|
|
|
|
$this->assertEquals('test6', $result['test6']['code']);
|
2023-06-07 14:39:34 +03:00
|
|
|
}
|
|
|
|
|
2022-07-20 12:46:32 +03:00
|
|
|
public function selectIntegrationDeliveriesProvider()
|
|
|
|
{
|
|
|
|
return [[
|
|
|
|
'data' => [
|
|
|
|
[
|
|
|
|
'code' => 'test1',
|
|
|
|
'integrationCode' => 'test2'
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'expected' => ['test1' => 'test2']
|
|
|
|
]];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function selectIntegrationPaymentsProvider()
|
|
|
|
{
|
|
|
|
return [[
|
|
|
|
'data' => [
|
|
|
|
[
|
|
|
|
'code' => 'test1',
|
|
|
|
'integrationModule' => 'test2'
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'expected' => ['test1']
|
|
|
|
]];
|
|
|
|
}
|
2020-07-22 15:11:27 +03:00
|
|
|
}
|