1
0
mirror of synced 2024-11-22 04:56:07 +03:00
This commit is contained in:
Sergey 2019-02-12 15:34:14 +03:00
parent fd2524b207
commit 3b97a7f06c
5 changed files with 60 additions and 7 deletions

View File

@ -1,3 +1,6 @@
## 2018-12-25 v.2.4.1
* Удалена генерация externalId покупателя при заказе от незарегестрированного пользователя
## 2018-12-25 v.2.4.0 ## 2018-12-25 v.2.4.0
* Добавлен функционал получения остатков из retailCRM * Добавлен функционал получения остатков из retailCRM

View File

@ -1 +1 @@
2.4.0 2.4.1

View File

@ -69,7 +69,6 @@ class Customer implements CustomerManagerInterface
$billing = $order->getBillingAddress(); $billing = $order->getBillingAddress();
$preparedCustomer = [ $preparedCustomer = [
'externalId' => uniqid(),
'email' => $billing->getEmail(), 'email' => $billing->getEmail(),
'firstName' => $billing->getFirstname(), 'firstName' => $billing->getFirstname(),
'patronymic' => $billing->getMiddlename(), 'patronymic' => $billing->getMiddlename(),

View File

@ -7,6 +7,8 @@ class CustomerTest extends \PHPUnit\Framework\TestCase
private $mockData; private $mockData;
private $mockCustomer; private $mockCustomer;
private $unit; private $unit;
private $mockOrder;
private $mockBillingAddress;
public function setUp() public function setUp()
{ {
@ -29,6 +31,59 @@ class CustomerTest extends \PHPUnit\Framework\TestCase
'getAddressesCollection' 'getAddressesCollection'
]) ])
->getMock(); ->getMock();
$this->mockOrder = $this->getMockBuilder(\Magento\Sales\Model\Order::class)
->disableOriginalConstructor()
->setMethods([
'getBillingAddress',
])
->getMock();
$this->mockBillingAddress = $this->getMockBuilder(\Magento\Customer\Model\Address\AddressModelInterface::class)
->disableOriginalConstructor()
->setMethods([
'getTelephone',
'getEmail',
'getData',
'getFirstname',
'getMiddlename',
'getLastname',
'getCountryId',
'getPostcode',
'getRegion',
'getCity',
'getStreet'
])
->getMockForAbstractClass();
$this->unit = new \Retailcrm\Retailcrm\Model\Service\Customer(
$this->mockData
);
}
public function testPrepareCustomerFromOrder()
{
$this->mockOrder->expects($this->any())
->method('getBillingAddress')
->willReturn($this->mockBillingAddress);
$result = $this->unit->prepareCustomerFromOrder($this->mockOrder);
$this->assertNotEmpty($result);
$this->assertInternalType('array', $result);
$this->assertArrayNotHasKey('externalId', $result);
$this->assertArrayHasKey('email', $result);
$this->assertArrayHasKey('firstName', $result);
$this->assertArrayHasKey('lastName', $result);
$this->assertArrayHasKey('patronymic', $result);
$this->assertArrayHasKey('address', $result);
$this->assertInternalType('array', $result['address']);
$this->assertArrayHasKey('countryIso', $result['address']);
$this->assertArrayHasKey('index', $result['address']);
$this->assertArrayHasKey('region', $result['address']);
$this->assertArrayHasKey('city', $result['address']);
$this->assertArrayHasKey('street', $result['address']);
$this->assertArrayHasKey('text', $result['address']);
} }
/** /**
@ -107,10 +162,6 @@ class CustomerTest extends \PHPUnit\Framework\TestCase
->method('getAddressesCollection') ->method('getAddressesCollection')
->willReturn([$mockAddress]); ->willReturn([$mockAddress]);
$this->unit = new \Retailcrm\Retailcrm\Model\Service\Customer(
$this->mockData
);
$result = $this->unit->process($this->mockCustomer); $result = $this->unit->process($this->mockCustomer);
$this->assertNotEmpty($result); $this->assertNotEmpty($result);

View File

@ -5,7 +5,7 @@
"retailcrm/api-client-php": "~5.0" "retailcrm/api-client-php": "~5.0"
}, },
"type": "magento2-module", "type": "magento2-module",
"version": "2.4.0", "version": "2.4.1",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"