2018-05-28 17:09:31 +03:00
|
|
|
<?php
|
|
|
|
|
2020-03-04 12:26:14 +03:00
|
|
|
if (class_exists('LegacyTests\Unit\ContextMocker')) {
|
|
|
|
class_alias('LegacyTests\Unit\ContextMocker', 'Tests\Unit\ContextMocker');
|
|
|
|
}
|
|
|
|
|
2018-05-28 17:09:31 +03:00
|
|
|
abstract class RetailcrmTestCase extends \PHPUnit\Framework\TestCase
|
|
|
|
{
|
2021-11-15 15:14:16 +03:00
|
|
|
private $apiMock;
|
|
|
|
|
|
|
|
protected $apiClientMock;
|
|
|
|
|
2018-05-28 17:09:31 +03:00
|
|
|
protected $contextMock;
|
|
|
|
|
2021-11-03 16:19:39 +07:00
|
|
|
protected function setUp()
|
2018-05-28 17:09:31 +03:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
2018-05-30 09:58:53 +03:00
|
|
|
if (version_compare(_PS_VERSION_, '1.7', '>')) {
|
2020-03-04 12:26:14 +03:00
|
|
|
$contextMocker = new \Tests\Unit\ContextMocker();
|
2018-05-30 09:58:53 +03:00
|
|
|
$this->contextMock = $contextMocker->mockContext();
|
|
|
|
}
|
2018-05-28 17:09:31 +03:00
|
|
|
}
|
|
|
|
|
2021-11-15 15:14:16 +03:00
|
|
|
protected function getApiMock(array $methods)
|
|
|
|
{
|
|
|
|
$this->apiClientMock = $this->apiMockBuilder($methods)->getMock();
|
|
|
|
|
|
|
|
$this->apiMock = new RetailcrmProxy('https://test.test', 'test_key');
|
|
|
|
$this->apiMock->setClient($this->apiClientMock);
|
|
|
|
|
|
|
|
return $this->apiMock;
|
|
|
|
}
|
|
|
|
|
2018-05-28 17:09:31 +03:00
|
|
|
protected function setConfig()
|
|
|
|
{
|
2018-10-05 17:50:20 +03:00
|
|
|
$delivery = json_encode(
|
2021-11-03 16:19:39 +07:00
|
|
|
[
|
|
|
|
1 => 'delivery',
|
|
|
|
]
|
2018-10-05 17:50:20 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
$status = json_encode(
|
2021-11-03 16:19:39 +07:00
|
|
|
[
|
2018-10-05 17:50:20 +03:00
|
|
|
9 => 'status',
|
|
|
|
10 => 'new',
|
2021-11-03 16:19:39 +07:00
|
|
|
11 => 'completed',
|
|
|
|
]
|
2018-10-05 17:50:20 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
$payment = json_encode(
|
2021-11-03 16:19:39 +07:00
|
|
|
[
|
2018-10-05 17:50:20 +03:00
|
|
|
'ps_checkpayment' => 'ps_checkpayment',
|
|
|
|
'bankwire' => 'bankwire',
|
2021-11-03 16:19:39 +07:00
|
|
|
'cheque' => 'cheque',
|
|
|
|
]
|
2018-10-05 17:50:20 +03:00
|
|
|
);
|
2018-05-28 17:09:31 +03:00
|
|
|
|
|
|
|
Configuration::updateValue('RETAILCRM_API_DELIVERY', $delivery);
|
|
|
|
Configuration::updateValue('RETAILCRM_API_STATUS', $status);
|
|
|
|
Configuration::updateValue('RETAILCRM_API_PAYMENT', $payment);
|
|
|
|
}
|
2021-11-15 15:14:16 +03:00
|
|
|
|
|
|
|
private function apiMockBuilder(array $methods)
|
|
|
|
{
|
|
|
|
return $this->getMockBuilder('RetailcrmApiClientV5')
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->setMethods($methods)
|
|
|
|
;
|
|
|
|
}
|
2018-05-28 17:09:31 +03:00
|
|
|
}
|