/** * Init settings bag */ protected function initSettings($wsiMode = false) { $testUsername = '******'; $this->settings->set('api_key', $this->encryptedApiKey); $this->settings->set('api_user', $testUsername); $this->settings->set('website_id', 1); $this->settings->set('start_sync_date', new \DateTime()); $this->settings->set('wsdl_url', 'http://localhost/?wsdl'); $this->transport->expects($this->once())->method('getSoapClient')->will($this->returnValue($this->soapClientMock)); $params = ['username' => $testUsername, 'apiKey' => $this->decryptedApiKey]; $params = $wsiMode ? [(object) $params] : $params; $result = $wsiMode ? (object) ['result' => $this->sessionId] : $this->sessionId; $this->soapClientMock->expects($this->at(0))->method('__soapCall')->with('login', $params)->will($this->returnValue($result)); }
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); }