2020-07-08 16:09:45 +03:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
class RetailcrmCorporateCustomerBuilderTest extends RetailcrmTestCase
|
|
|
|
|
{
|
|
|
|
|
protected $corporateCustomer;
|
|
|
|
|
|
2021-11-03 16:19:39 +07:00
|
|
|
|
protected function setUp()
|
2020-07-08 16:09:45 +03:00
|
|
|
|
{
|
|
|
|
|
parent::setUp();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testBuild()
|
|
|
|
|
{
|
|
|
|
|
$this->corporateCustomer = new RetailcrmCorporateCustomerBuilder();
|
|
|
|
|
|
|
|
|
|
$this->corporateCustomer
|
|
|
|
|
->setDataCrm($this->getDataCrm())
|
2021-11-03 16:19:39 +07:00
|
|
|
|
->build()
|
|
|
|
|
;
|
2020-07-08 16:09:45 +03:00
|
|
|
|
|
|
|
|
|
$result = new RetailcrmCustomerBuilderResult(null, null);
|
|
|
|
|
|
|
|
|
|
$this->assertInstanceOf(get_class($result), $this->corporateCustomer->getData());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetData()
|
|
|
|
|
{
|
|
|
|
|
$this->corporateCustomer = new RetailcrmCorporateCustomerBuilder();
|
|
|
|
|
|
|
|
|
|
$this->corporateCustomer
|
|
|
|
|
->setDataCrm($this->getDataCrm())
|
2021-11-03 16:19:39 +07:00
|
|
|
|
->build()
|
|
|
|
|
;
|
2020-07-08 16:09:45 +03:00
|
|
|
|
|
|
|
|
|
$builtCustomer = $this->corporateCustomer->getData()->getCustomer();
|
|
|
|
|
$builtAddress = $this->corporateCustomer->getData()->getCustomerAddress();
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($builtCustomer instanceof Customer
|
|
|
|
|
|| $builtCustomer instanceof CustomerCore);
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($builtAddress instanceof Address
|
|
|
|
|
|| $builtAddress instanceof AddressCore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCorrectDataCorporateCustomer()
|
|
|
|
|
{
|
|
|
|
|
$this->corporateCustomer = new RetailcrmCorporateCustomerBuilder();
|
|
|
|
|
|
|
|
|
|
$this->corporateCustomer
|
|
|
|
|
->setDataCrm($this->getDataCrm())
|
|
|
|
|
->setCustomer($this->getDataBuilder())
|
|
|
|
|
->setCompanyName('Test')
|
|
|
|
|
->setCompanyInn(5666)
|
2021-11-03 16:19:39 +07:00
|
|
|
|
->build()
|
|
|
|
|
;
|
2020-07-08 16:09:45 +03:00
|
|
|
|
|
|
|
|
|
$customerResult = $this->corporateCustomer->getData()->getCustomer();
|
|
|
|
|
$this->assertEquals('April', $customerResult->firstname);
|
|
|
|
|
$this->assertEquals('Iphone', $customerResult->lastname);
|
2021-11-03 16:19:39 +07:00
|
|
|
|
$this->assertFalse($customerResult->newsletter);
|
2020-07-08 16:09:45 +03:00
|
|
|
|
$this->assertEquals('1997-04-09', $customerResult->birthday);
|
|
|
|
|
$this->assertEquals(2, $customerResult->id_gender);
|
|
|
|
|
$this->assertEquals('hello@world.ru', $customerResult->email);
|
|
|
|
|
|
|
|
|
|
$addressResult = $this->corporateCustomer->getData()->getCustomerAddress();
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(Country::getByIso('RU'), $addressResult->id_country);
|
|
|
|
|
$this->assertEquals('г. Москва', $addressResult->city);
|
|
|
|
|
$this->assertEquals('Test', $addressResult->company);
|
|
|
|
|
$this->assertEquals(5666, $addressResult->vat_number);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-03 16:19:39 +07:00
|
|
|
|
private function getDataBuilder()
|
|
|
|
|
{
|
|
|
|
|
return [
|
2020-07-08 16:09:45 +03:00
|
|
|
|
'type' => 'customer_corporate',
|
|
|
|
|
'id' => 9090,
|
|
|
|
|
'nickName' => 'TestName',
|
2021-11-03 16:19:39 +07:00
|
|
|
|
'mainAddress' => [
|
2020-07-08 16:09:45 +03:00
|
|
|
|
'id' => 4001,
|
2021-11-03 16:19:39 +07:00
|
|
|
|
'name' => 'Test',
|
|
|
|
|
],
|
2020-07-08 16:09:45 +03:00
|
|
|
|
'createdAt' => '2020-02-17 07:44:31',
|
|
|
|
|
'vip' => false,
|
|
|
|
|
'bad' => false,
|
|
|
|
|
'site' => 'opencart',
|
2021-11-03 16:19:39 +07:00
|
|
|
|
'tags' => [],
|
2020-07-08 16:09:45 +03:00
|
|
|
|
'marginSumm' => 0,
|
|
|
|
|
'totalSumm' => 0,
|
|
|
|
|
'averageSumm' => 0,
|
|
|
|
|
'ordersCount' => 0,
|
|
|
|
|
'costSumm' => 0,
|
2021-11-03 16:19:39 +07:00
|
|
|
|
'customFields' => [],
|
2020-07-08 16:09:45 +03:00
|
|
|
|
'personalDiscount' => 0,
|
2021-11-03 16:19:39 +07:00
|
|
|
|
'mainCustomerContact' => [
|
2020-07-08 16:09:45 +03:00
|
|
|
|
'id' => 37,
|
2021-11-03 16:19:39 +07:00
|
|
|
|
'customer' => [
|
|
|
|
|
'id' => 9089,
|
|
|
|
|
],
|
|
|
|
|
'companies' => [],
|
|
|
|
|
],
|
|
|
|
|
'mainCompany' => [
|
2020-07-08 16:09:45 +03:00
|
|
|
|
'id' => 34,
|
|
|
|
|
'name' => 'Test',
|
2021-11-03 16:19:39 +07:00
|
|
|
|
'contragentInn' => 5666,
|
|
|
|
|
],
|
|
|
|
|
];
|
2020-07-08 16:09:45 +03:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-03 16:19:39 +07:00
|
|
|
|
private function getDataCrm()
|
|
|
|
|
{
|
|
|
|
|
return [
|
2020-07-08 16:09:45 +03:00
|
|
|
|
'type' => 'customer',
|
|
|
|
|
'id' => 9000,
|
|
|
|
|
'externalId' => '1777754',
|
|
|
|
|
'isContact' => false,
|
|
|
|
|
'createdAt' => '2020-04-09 16:55:59',
|
|
|
|
|
'vip' => true,
|
|
|
|
|
'bad' => true,
|
|
|
|
|
'site' => '127-0-0-1-8080',
|
2021-11-03 16:19:39 +07:00
|
|
|
|
'contragent' => [
|
|
|
|
|
'contragentType' => 'individual',
|
|
|
|
|
],
|
|
|
|
|
'subscribed' => false,
|
|
|
|
|
'tags' => [],
|
2020-07-08 16:09:45 +03:00
|
|
|
|
'marginSumm' => 0,
|
|
|
|
|
'totalSumm' => 0,
|
|
|
|
|
'averageSumm' => 0,
|
|
|
|
|
'ordersCount' => 0,
|
|
|
|
|
'costSumm' => 0,
|
2021-11-03 16:19:39 +07:00
|
|
|
|
'customFields' => [],
|
2020-07-08 16:09:45 +03:00
|
|
|
|
'personalDiscount' => 0,
|
2021-11-03 16:19:39 +07:00
|
|
|
|
'address' => [
|
2020-07-08 16:09:45 +03:00
|
|
|
|
'id' => 9718,
|
|
|
|
|
'countryIso' => 'RU',
|
|
|
|
|
'region' => 'Moscow',
|
|
|
|
|
'city' => 'г. Москва',
|
|
|
|
|
'index' => '344004',
|
2021-11-03 16:19:39 +07:00
|
|
|
|
'text' => 'MAY',
|
|
|
|
|
],
|
|
|
|
|
'segments' => [],
|
2020-07-08 16:09:45 +03:00
|
|
|
|
'firstName' => 'April',
|
|
|
|
|
'lastName' => 'Iphone',
|
|
|
|
|
'email' => 'hello@world.ru',
|
|
|
|
|
'sex' => 'female',
|
2021-11-03 16:19:39 +07:00
|
|
|
|
'birthday' => '1997-04-09',
|
|
|
|
|
];
|
2020-07-08 16:09:45 +03:00
|
|
|
|
}
|
|
|
|
|
}
|