/** * @return \YellowCube\Config */ public function getServiceConfig() { $helper = Mage::helper('swisspost_yellowcube'); $certificatePath = $helper->getCertificatePath(); $certificatePassword = $helper->getCertificatePassword(); if (!$helper->isConfigured()) { Mage::throwException($helper->__('YellowCube Extension is not properly configured. Please <a href="%s">configure</a> it before to continue.', Mage::getUrl('system_config/edit/section/carriers'))); } $config = new YellowCube\Config($helper->getSenderId(), $helper->getEndpoint(), null, $helper->getOperationMode()); // Certificate handling if (in_array($helper->getOperationMode(), array('P', 'T', 'D'))) { if (!empty($certificatePath)) { $config->setCertificateFilePath($certificatePath, $certificatePassword); } } return $config; }
/** * Returns the config to use. * * @return \YellowCube\Config */ protected function getConfig() { if (empty($this->config)) { $this->config = Config::testConfig(); } return $this->config; }
<?php require __DIR__ . '/../vendor/autoload.php'; use YellowCube\Config; $service = new YellowCube\Service(Config::testConfig()); $response = $service->getYCCustomerOrderStatus(5523); var_dump($response); assert($response->isSuccess(), 'Getting status for order failed.'); echo "Successfully retrieved status for order with reference " . $response->getReference();
function it_creates_a_control_reference_with_timeout(Config $config) { $config->getTimeoutSec()->willReturn(30); $this::fromConfig('WAR', $config)->getTransMaxWait()->shouldEqual(30); }