diff --git a/CHACNGELOG.md b/CHACNGELOG.md index 2bfc3a3..bd1d9c5 100644 --- a/CHACNGELOG.md +++ b/CHACNGELOG.md @@ -1,3 +1,6 @@ +## 2018-12-25 v.2.4.1 +* Удалена генерация externalId покупателя при заказе от незарегестрированного пользователя + ## 2018-12-25 v.2.4.0 * Добавлен функционал получения остатков из retailCRM diff --git a/VERSION b/VERSION index 9183195..58073ef 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.4.0 \ No newline at end of file +2.4.1 \ No newline at end of file diff --git a/src/Model/Service/Customer.php b/src/Model/Service/Customer.php index 1ba449c..3c865c9 100644 --- a/src/Model/Service/Customer.php +++ b/src/Model/Service/Customer.php @@ -69,7 +69,6 @@ class Customer implements CustomerManagerInterface $billing = $order->getBillingAddress(); $preparedCustomer = [ - 'externalId' => uniqid(), 'email' => $billing->getEmail(), 'firstName' => $billing->getFirstname(), 'patronymic' => $billing->getMiddlename(), diff --git a/src/Test/Unit/Model/Service/CustomerTest.php b/src/Test/Unit/Model/Service/CustomerTest.php index c24f98a..3a2126d 100644 --- a/src/Test/Unit/Model/Service/CustomerTest.php +++ b/src/Test/Unit/Model/Service/CustomerTest.php @@ -7,6 +7,8 @@ class CustomerTest extends \PHPUnit\Framework\TestCase private $mockData; private $mockCustomer; private $unit; + private $mockOrder; + private $mockBillingAddress; public function setUp() { @@ -29,6 +31,59 @@ class CustomerTest extends \PHPUnit\Framework\TestCase 'getAddressesCollection' ]) ->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') ->willReturn([$mockAddress]); - $this->unit = new \Retailcrm\Retailcrm\Model\Service\Customer( - $this->mockData - ); - $result = $this->unit->process($this->mockCustomer); $this->assertNotEmpty($result); diff --git a/src/composer.json b/src/composer.json index 97f5bc7..f6e90ec 100644 --- a/src/composer.json +++ b/src/composer.json @@ -5,7 +5,7 @@ "retailcrm/api-client-php": "~5.0" }, "type": "magento2-module", - "version": "2.4.0", + "version": "2.4.1", "license": [ "OSL-3.0", "AFL-3.0"