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); }
/** * Check if magento extension not installed and fix data set * In the magento version up to 1.8.0.0 we can send only: email, firstname, lastname. * * @param \stdClass $remoteData */ protected function fixDataIfExtensionNotInstalled(\stdClass $remoteData) { if (!$this->transport->isExtensionInstalled()) { foreach ($remoteData as $key => $value) { if (!in_array($key, $this->clearMagentoFields)) { unset($remoteData->{$key}); } } } }
/** * @dataProvider wsiDataProvider * * @param mixed $actionParams * @param mixed $expectedParams * @param \stdClass $remoteResponse * @param mixed $expectedData */ public function testWSICompatibility($actionParams, $expectedParams, $remoteResponse, $expectedData) { $this->settings->set('wsi_mode', true); $this->initSettings(true); $testActionName = 'testAction'; $this->soapClientMock->expects($this->at(1))->method('__soapCall')->with($this->equalTo($testActionName), $this->equalTo([(object) $expectedParams]))->will($this->returnValue($remoteResponse)); $this->transport->init($this->transportEntity); $result = $this->transport->call($testActionName, $actionParams); $this->assertEquals($expectedData, $result); }
/** * @dataProvider methodsDataProvider * * @param string $method * @param $endpoint * @param $expectedParameters * @param $result * @param array|null $arguments * @param bool $withPing * @param bool $extensionInstalled */ public function testCalls($method, $endpoint, $expectedParameters, $result, array $arguments = null, $withPing = false, $extensionInstalled = true) { $this->initSettings(false, ['oroPing']); $this->transport->init($this->transportEntity); $this->soapClientMock->expects($withPing ? $this->at(1) : $this->once())->method('__soapCall')->with($endpoint, $expectedParameters)->will($this->returnValue($result)); $pingResponse = null; if ($withPing) { if ($extensionInstalled) { $pingResponse = (object) ['version' => '1.2.3', 'mage_version' => '1.8.0.0', 'admin_url' => 'http://localhost/admin/']; } $this->soapClientMock->expects($this->at(0))->method('__soapCall')->with(SoapTransport::ACTION_PING, ['sessionId' => $this->sessionId])->will($this->returnValue($pingResponse)); } $this->assertEquals($result, call_user_func_array([$this->transport, $method], $arguments)); }
/** * Retrieve store ids for given website * * @param $websiteId * * @return array * @throws \LogicException */ protected function getStoresByWebsiteId($websiteId) { if (empty($this->storesByWebsite)) { $this->storesByWebsite[$websiteId] = []; $storesList = $this->transport->getStores(); foreach ($storesList as $store) { $this->storesByWebsite[$store['website_id']][] = $store['store_id']; } } $stores = $this->storesByWebsite[$websiteId]; if (empty($this->storesByWebsite[$websiteId])) { throw new \LogicException(sprintf('Could not resolve store dependency for website id: %d', $websiteId)); } return $stores; }