/** * @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); }
/** * {@inheritDoc} */ public function write(array $items) { foreach ($items as $item) { if (!empty($item->object)) { try { /** @var Customer $customer */ $customer = $item->entity; $channel = $customer->getChannel(); if (!empty($item->object['email'])) { $item->object['email'] = $this->emailParser($item->object['email']); } $this->transport->init($channel->getTransport()); $localUpdatedData = $this->customerSerializer->normalize($item->entity, null, $item->object); // REMOTE WINS $isRemoteWins = $channel->getSynchronizationSettings()->offsetGetOr('syncPriority') === TwoWaySyncConnectorInterface::REMOTE_WINS; if ($isRemoteWins) { $remoteChanges = $this->getCustomerRemoteChangeSet($item, array_keys($localUpdatedData)); $this->setChangedData($customer, $item->object); $this->setChangedData($customer, $remoteChanges); $this->em->persist($customer); $customerForMagento = $this->customerSerializer->normalize($customer); $this->updateRemoteData($customer->getOriginId(), $customerForMagento); } else { // local wins $this->updateRemoteData($customer->getOriginId(), $localUpdatedData); $this->setChangedData($customer, $item->object); $this->em->persist($customer); } // process addresses if (isset($item->object['addresses'])) { $this->processAddresses($item->object['addresses'], $isRemoteWins, $customer); } } catch (\Exception $e) { //process another entity even in case if exception thrown continue; } } } $this->em->flush(); }
/** * @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)); }