1
0
mirror of synced 2024-11-28 07:56:06 +03:00

Merge pull request #22 from sergeygw1990/master

v2.4.1
This commit is contained in:
Alex Lushpai 2019-02-14 13:23:14 +03:00 committed by GitHub
commit 6e9629efef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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"