Пример #1
0
 /**
  * @dataProvider addressTypesUpdateDataProvider
  *
  * @param string          $priority
  * @param ArrayCollection $remoteTypes
  * @param ArrayCollection $localTypes
  * @param ArrayCollection $contactTypes
  * @param array           $expectedTypeNames
  */
 public function testAddressTypesUpdate($priority, ArrayCollection $remoteTypes, ArrayCollection $localTypes, ArrayCollection $contactTypes, array $expectedTypeNames)
 {
     $channel = new Channel();
     $channel->getSynchronizationSettingsReference()->offsetSet('syncPriority', $priority);
     $testCountry = new Country('US');
     $contact = new Contact();
     $contactAddress = new ContactAddress();
     $contactAddress->setId(self::TEST_CONTACT_ADDRESS_ID);
     $contactAddress->setTypes($contactTypes);
     $contactAddress->setCountry($testCountry);
     $contact->addAddress($contactAddress);
     $phone = new ContactPhone();
     $phone->setPhone('123-123-123');
     $phone->setOwner($contact);
     $contact->addPhone($phone);
     $localCustomer = new Customer();
     $localAddress = new Address();
     $localAddress->setContactAddress($contactAddress);
     $localAddress->setTypes($localTypes);
     $localAddress->setCountry($testCountry);
     $localAddress->setPhone('123-123-123');
     $localAddress->setContactPhone($phone);
     $localCustomer->addAddress($localAddress);
     $remoteCustomer = new Customer();
     $remoteAddress = new Address();
     $remoteAddress->setContactAddress($contactAddress);
     $remoteAddress->setTypes($remoteTypes);
     $remoteAddress->setCountry($testCountry);
     $remoteAddress->setContactPhone($phone);
     $remoteCustomer->addAddress($remoteAddress);
     $helper = $this->getHelper($channel);
     $helper->merge($remoteCustomer, $localCustomer, $contact);
     $this->assertCount(1, $contact->getAddresses());
     $this->assertEquals($expectedTypeNames, $contactAddress->getTypeNames());
 }
Пример #2
0
 public function dataTest()
 {
     $testContact = new ExtendContact();
     $testContactAddress = new ContactAddress();
     $testContactEmail = new ContactEmail();
     $testContactPhone = new ContactPhone();
     $testContactAddress->setOwner($testContact);
     $testContactEmail->setOwner($testContact);
     $testContactPhone->setOwner($testContact);
     $testMagentoCustomer = new ExtendCustomer();
     $channel = new Channel();
     $channel->getSynchronizationSettingsReference()->offsetSet('isTwoWaySyncEnabled', true);
     $channel->setName('test');
     $channel->setEnabled(true);
     $testMagentoCustomer->setChannel($channel);
     return ['Updated contact' => [$testContact, $testMagentoCustomer, $channel, [], [$testContact], [], true, true, true, true, true], 'Inserted contact' => [$testContact, $testMagentoCustomer, $channel, [$testContact], [], [], true, false, false, true, false], 'Deleted contact' => [$testContact, $testMagentoCustomer, $channel, [], [], [$testContact], true, true, true, false, true], 'Updated contact with testContactAddress' => [$testContact, $testMagentoCustomer, $channel, [], [$testContact, $testContactAddress], [], true, true, true, true, true], 'Test process Contact Address' => [$testContact, $testMagentoCustomer, $channel, [], [$testContactAddress], [], true, true, true, false, true], 'Test deleted Contact Address' => [$testContact, $testMagentoCustomer, $channel, [], [], [$testContactAddress], true, true, true, false, true]];
 }
Пример #3
0
 public function testUpdateAddress()
 {
     $transportSetting = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport');
     $channel = new Channel();
     $channel->setTransport($transportSetting);
     $channel->getSynchronizationSettingsReference()->offsetSet('syncPriority', TwoWaySyncConnectorInterface::LOCAL_WINS);
     $customer = new Customer();
     $customer->setOriginId(self::TEST_CUSTOMER_ID);
     $customer->setChannel($channel);
     $customer->setFirstName(self::TEST_CUSTOMER_FIRSTNAME);
     $customer->setLastName(self::TEST_CUSTOMER_LASTNAME);
     $contactAddress = new ContactAddress();
     $address = new Address();
     $address->setFirstName(self::TEST_FIRSTNAME);
     $address->setCountry(new Country(self::TEST_ADDRESS_COUNTRY));
     $address->setRegionText(self::TEST_ADDRESS_REGION);
     $address->setStreet(self::TEST_ADDRESS_STREET);
     $address->setContactAddress($contactAddress);
     $address->setOriginId(1);
     $this->transport->expects($this->once())->method('init');
     $this->regionConverter->expects($this->once())->method('toMagentoData')->with($this->identicalTo($address))->will($this->returnValue(['region' => self::TEST_ADDRESS_REGION_RESOLVED, 'region_id' => null]));
     $this->transport->expects($this->at(2))->method('getCustomerAddresses')->with($this->identicalTo($customer))->will($this->returnValue([(object) ['customer_address_id' => 1, 'telephone' => '911', 'middlename' => 'testMiddleName', 'suffix' => 'testSuffix', 'company' => 'testCompany', 'city' => 'testCity', 'is_default_shipping' => false, 'is_default_billing' => false]]));
     $this->transport->expects($this->at(3))->method('call')->with($this->equalTo(SoapTransport::ACTION_CUSTOMER_ADDRESS_UPDATE), $this->equalTo(['addressId' => 1, 'addressData' => ['prefix' => null, 'firstname' => 'newName', 'middlename' => null, 'lastname' => 'newLastName', 'suffix' => null, 'company' => null, 'street' => [0 => self::TEST_ADDRESS_STREET, 1 => null], 'city' => null, 'postcode' => null, 'country_id' => self::TEST_ADDRESS_COUNTRY, 'region' => self::TEST_ADDRESS_REGION_RESOLVED, 'region_id' => null, 'created_at' => null, 'updated_at' => null, 'is_default_billing' => false, 'is_default_shipping' => false, 'telephone' => 'no phone']]))->will($this->returnValue(true));
     $this->em->expects($this->atLeastOnce())->method('persist');
     $this->em->expects($this->once())->method('flush');
     $data = [];
     array_push($data, (object) ['entity' => $customer, 'object' => ['addresses' => [['entity' => $address, 'status' => AbstractReverseProcessor::UPDATE_ENTITY, 'object' => ['firstname' => 'newName', 'lastname' => 'newLastName']]]]]);
     $this->writer->write($data);
 }