2018-06-13 16:13:08 +03:00
|
|
|
<?php
|
|
|
|
|
2018-09-27 16:46:04 +03:00
|
|
|
namespace Tests;
|
|
|
|
|
|
|
|
class CustomerRetailcrmLibraryTest extends OpenCartTest
|
2018-06-13 16:13:08 +03:00
|
|
|
{
|
2018-09-27 16:46:04 +03:00
|
|
|
private $customer;
|
2018-06-13 16:13:08 +03:00
|
|
|
private $apiClientMock;
|
|
|
|
|
|
|
|
const CUSTOMER_ID = 1;
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->apiClientMock = $this->getMockBuilder(\RetailcrmProxy::class)
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->setMethods(array(
|
2018-09-27 16:46:04 +03:00
|
|
|
'customersCreate',
|
2018-06-13 16:13:08 +03:00
|
|
|
'customersEdit'
|
|
|
|
))
|
|
|
|
->getMock();
|
|
|
|
|
2018-09-27 16:46:04 +03:00
|
|
|
$retailcrm = new \Retailcrm\Retailcrm(self::$registry);
|
|
|
|
$this->customer = $retailcrm->createObject(\Retailcrm\Customer::class);
|
2018-06-13 16:13:08 +03:00
|
|
|
}
|
|
|
|
|
2018-09-27 16:46:04 +03:00
|
|
|
public function testPrepareCustomer()
|
2018-06-13 16:13:08 +03:00
|
|
|
{
|
2018-09-27 16:46:04 +03:00
|
|
|
$customerModel = $this->loadModel('account/customer');
|
2018-06-13 16:13:08 +03:00
|
|
|
$customer = $customerModel->getCustomer(self::CUSTOMER_ID);
|
|
|
|
|
2018-09-27 16:46:04 +03:00
|
|
|
$this->customer->prepare($customer);
|
|
|
|
$customerSend = $this->customer->getData();
|
2018-06-13 16:13:08 +03:00
|
|
|
|
|
|
|
$this->assertArrayHasKey('externalId', $customerSend);
|
|
|
|
$this->assertEquals(self::CUSTOMER_ID, $customerSend['externalId']);
|
|
|
|
$this->assertArrayHasKey('firstName', $customerSend);
|
|
|
|
$this->assertEquals('Test', $customerSend['firstName']);
|
|
|
|
$this->assertArrayHasKey('lastName', $customerSend);
|
|
|
|
$this->assertEquals('Test', $customerSend['lastName']);
|
|
|
|
$this->assertArrayHasKey('email', $customerSend);
|
|
|
|
$this->assertEquals('test@mail.ru', $customerSend['email']);
|
|
|
|
$this->assertArrayHasKey('phones', $customerSend);
|
|
|
|
$this->assertEquals('+7 (000) 000-00-00', $customerSend['phones'][0]['number']);
|
|
|
|
}
|
2018-09-27 16:46:04 +03:00
|
|
|
}
|