/** * Create REST client * * @param Transport $transportEntity * @return RestClientInterface * @throws InvalidConfigurationException */ protected function createRestClient(Transport $transportEntity) { $settings = $transportEntity->getSettingsBag(); $baseUrl = $this->getClientBaseUrl($settings); $clientOptions = $this->getClientOptions($settings); return $this->getClientFactory()->createRestClient($baseUrl, $clientOptions); }
/** * {@inheritdoc} */ public function init(Transport $transportEntity) { $apiKey = $transportEntity->getSettingsBag()->get('apiKey'); if (!$apiKey) { throw new RequiredOptionException('apiKey'); } $this->client = $this->mailChimpClientFactory->create($apiKey); }
/** * Setup test entity */ protected function setUp() { $this->transport = $this->getMockForAbstractClass('Oro\\Bundle\\IntegrationBundle\\Provider\\SOAPTransport', [], '', true, true, true, ['getSoapClient', 'getSleepBetweenAttempt']); $this->soapClientMock = $this->getMockBuilder('\\SoapClient')->disableOriginalConstructor()->setMethods(['__soapCall', '__getLastResponseHeaders'])->getMock(); $this->settings = new ParameterBag(); $this->transportEntity = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport'); $this->transportEntity->expects($this->any())->method('getSettingsBag')->will($this->returnValue($this->settings)); $this->transport->expects($this->any())->method('getSleepBetweenAttempt')->will($this->returnValue(1)); }
protected function setUp() { $encoder = $this->getMock('Oro\\Bundle\\SecurityBundle\\Encoder\\Mcrypt'); $encoder->expects($this->any())->method('decryptData')->with($this->encryptedApiKey)->will($this->returnValue($this->decryptedApiKey)); $this->transport = $this->getMock('OroCRM\\Bundle\\MagentoBundle\\Provider\\Transport\\SoapTransport', ['getSoapClient'], [$encoder]); $this->soapClientMock = $this->getMockBuilder('\\SoapClient')->disableOriginalConstructor()->setMethods(['__soapCall'])->getMock(); $this->settings = new ParameterBag(); $this->transportEntity = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport'); $this->transportEntity->expects($this->any())->method('getSettingsBag')->will($this->returnValue($this->settings)); }
/** * {@inheritdoc} */ public function init(Transport $transportEntity) { $this->resetAttemptCount(); $this->settings = $transportEntity->getSettingsBag(); $wsdlUrl = $this->settings->get('wsdl_url'); if (!$wsdlUrl) { throw new InvalidConfigurationException("SOAP Transport require 'wsdl_url' option to be defined."); } $this->client = $this->getSoapClient($wsdlUrl); }
protected function setUp() { $encoder = $this->getMock('Oro\\Bundle\\SecurityBundle\\Encoder\\Mcrypt'); $encoder->expects($this->any())->method('decryptData')->with($this->encryptedApiKey)->will($this->returnValue($this->decryptedApiKey)); $wsdlManager = $this->getMockBuilder('OroCRM\\Bundle\\MagentoBundle\\Service\\WsdlManager')->disableOriginalConstructor()->getMock(); $this->transport = $this->getMock('OroCRM\\Bundle\\MagentoBundle\\Provider\\Transport\\SoapTransport', ['getSoapClient'], [$encoder, $wsdlManager]); // Do not attempt to run request several times in Unit test. This leads to sleep and test performance impact $this->transport->setMultipleAttemptsEnabled(false); $this->soapClientMock = $this->getMockBuilder('\\SoapClient')->disableOriginalConstructor()->getMock(); $this->settings = new ParameterBag(); $this->transportEntity = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport'); $this->transportEntity->expects($this->any())->method('getSettingsBag')->will($this->returnValue($this->settings)); }
/** * {@inheritdoc} */ public function init(Transport $transportEntity) { $token = $transportEntity->getSettingsBag()->get('token'); if (empty($token)) { throw new InvalidConfigurationException('GitHub API token isn\'t set.'); } $this->gitHubOrganization = $transportEntity->getSettingsBag()->get('organization'); if (empty($this->gitHubOrganization)) { throw new InvalidConfigurationException('GitHub organization isn\'t set.'); } $this->gitHubRepo = $transportEntity->getSettingsBag()->get('repo'); if (empty($this->gitHubRepo)) { throw new InvalidConfigurationException('GitHub repo isn\'t set.'); } $this->client = $this->gitHubClientFactory->createClient(); $this->client->authenticate($token, null, Client::AUTH_URL_TOKEN); return $this->client; }
/** * {@inheritdoc} */ public function init(Transport $transportEntity) { /** * Cache WSDL and force transport entity to use it instead of original URL. * This should be done before parent::init as settings will be cached there. */ if ($transportEntity instanceof MagentoSoapTransport) { $wsdlUrl = $transportEntity->getWsdlUrl(); // Save auth information to be able to perform requests. $urlParts = parse_url($wsdlUrl); if (isset($urlParts['user'], $urlParts['pass'])) { $this->auth['login'] = $urlParts['user']; $this->auth['password'] = $urlParts['pass']; } // Load WSDL to local cache. if (!$this->wsdlManager->isCacheLoaded($wsdlUrl)) { $this->wsdlManager->loadWsdl($wsdlUrl); } // Set cached WSDL path to transport entity. $transportEntity->setWsdlCachePath($this->wsdlManager->getCachedWsdlPath($wsdlUrl)); } parent::init($transportEntity); $wsiMode = $this->settings->get('wsi_mode', false); $apiUser = $this->settings->get('api_user', false); $apiKey = $this->settings->get('api_key', false); $apiKey = $this->encoder->decryptData($apiKey); if (!$apiUser || !$apiKey) { throw new InvalidConfigurationException("Magento SOAP transport require 'api_key' and 'api_user' settings to be defined."); } // revert initial state $this->isExtensionInstalled = null; $this->adminUrl = null; $this->isWsiMode = $wsiMode; /** @var string sessionId returned by Magento API login method */ $this->sessionId = null; $this->sessionId = $this->call('login', ['username' => $apiUser, 'apiKey' => $apiKey]); $this->checkExtensionFunctions(); }
public function init(Transport $transportEntity) { $this->settings = $transportEntity->getSettingsBag(); $this->client = new GRClient($this->settings->get('api_url')); }
public function testEntityMethods() { $this->assertNull($this->entity->getId()); }