Exemplo n.º 1
0
 /**
  * @return array
  */
 public function sourceDataProvider()
 {
     $address1 = new Address();
     $address2 = new Address();
     $badSource = null;
     $region1 = new BAPRegion(self::TEST_REGION_COMBINED_CODE);
     $region1->setName(self::TEST_REGION_NAME);
     $address1->setRegion($region1);
     $address2->setRegionText(self::TEST_REGION_NAME);
     return ['take region from address, found in magento DB, use region ID' => [$address1, true, ['region' => null, 'region_id' => self::TEST_MAGENTO_REGION_ID]], 'take region from address, not found in magento DB, use region name' => [$address1, false, ['region' => self::TEST_REGION_NAME, 'region_id' => null]], 'region not set, use region text' => [$address2, null, ['region' => self::TEST_REGION_NAME, 'region_id' => null]], 'bad type given' => [$badSource, null, null, '\\InvalidArgumentException']];
 }
Exemplo n.º 2
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);
 }