Exemplo n.º 1
0
 /**
  * __construct
  *
  * @param integer $status  Action status
  * @param string  $message Status info OPTIONAL
  * @param integer $code    Code OPTIONAL
  *
  * @return void
  */
 public function __construct($status, $message = '', $code = 0)
 {
     parent::__construct();
     if ($this->checkStatus($status)) {
         $this->status = $status;
         $this->message = $message;
         $this->code = $code;
     } else {
         $this->doDie('\\XLite\\Model\\ActionStatus::__construct(): unallowed status - "' . strval($status) . '"');
     }
 }
Exemplo n.º 2
0
 /**
  * testGetDestinationAddress
  *
  * @return void
  * @access public
  * @see    ____func_see____
  * @since  1.0.0
  */
 public function testGetDestinationAddress()
 {
     $order = $this->getTestOrder(true);
     $m = $order->getModifier('shipping', 'SHIPPING')->getModifier();
     $address = \XLite\Model\Shipping::getInstance()->getDestinationAddress($m);
     $this->assertTrue(is_array($address), 'getDestinationAddress() must return an array');
     $this->assertArrayHasKey('address', $address, 'Address must contain "address" key');
     $this->assertArrayHasKey('city', $address, 'Address must contain "city" key');
     $this->assertArrayHasKey('country', $address, 'Address must contain "country" key');
     $this->assertArrayHasKey('state', $address, 'Address must contain "state" key');
     $this->assertArrayHasKey('zipcode', $address, 'Address must contain "zipcode" key');
     $order = $this->getTestOrder(false);
     $m = $order->getModifier('shipping', 'SHIPPING')->getModifier();
     $address = \XLite\Model\Shipping::getInstance()->getDestinationAddress($m);
     $this->assertTrue(is_array($address), 'getDestinationAddress() must return an array');
     $this->assertArrayHasKey('address', $address, 'Address must contain "address" key');
     $this->assertArrayHasKey('city', $address, 'Address must contain "city" key');
     $this->assertArrayHasKey('country', $address, 'Address must contain "country" key');
     $this->assertArrayHasKey('state', $address, 'Address must contain "state" key');
     $this->assertArrayHasKey('zipcode', $address, 'Address must contain "zipcode" key');
     $this->assertEquals(\XLite\Base::getInstance()->config->Shipping->anonymous_country, $address['country'], 'Country does not match');
     $this->assertEquals(\XLite\Base::getInstance()->config->Shipping->anonymous_state, $address['state'], 'state does not match');
     $this->assertEquals(\XLite\Base::getInstance()->config->Shipping->anonymous_zipcode, $address['zipcode'], 'zipcode does not match');
     $this->assertEquals(\XLite\Base::getInstance()->config->Shipping->anonymous_city, $address['city'], 'city does not match');
     $this->assertEquals(\XLite\Base::getInstance()->config->Shipping->anonymous_address, $address['address'], 'address does not match');
 }
Exemplo n.º 3
0
 public function __construct()
 {
     parent::__construct();
     $this->config = \XLite\Core\Config::getInstance()->CDev->XPaymentsConnector;
     $this->response = new \XLite\Module\CDev\XPaymentsConnector\Transport\Response();
 }
Exemplo n.º 4
0
 /**
  * Define and set handler attributes; initialize handler
  *
  * @param array $params Handler params OPTIONAL
  *
  * @return void
  */
 public function __construct(array $params = array())
 {
     parent::__construct();
     $this->setWidgetParams($params);
 }
Exemplo n.º 5
0
Arquivo: Auth.php Projeto: kingsj/core
 /**
  * Protected constructor
  *
  * @return void
  */
 protected function __construct()
 {
     parent::__construct();
     $this->resetProfileCache();
 }
Exemplo n.º 6
0
 /**
  * testGetRates
  *
  * @return void
  * @access public
  * @see    ____func_see____
  * @since  1.0.0
  */
 public function testGetRates()
 {
     $processor = new XLite\Module\CDev\AustraliaPost\Model\Shipping\Processor\AustraliaPost();
     // Test on anonymous order
     $tmpConfig = \XLite\Base::getInstance()->config->Company;
     \XLite\Base::getInstance()->config->Company->location_country = 'AU';
     \XLite\Base::getInstance()->config->Company->location_zipcode = '3146';
     $m = $this->getTestOrder(false)->getModifier('shipping', 'SHIPPING')->getModifier();
     $rates = $processor->getRates($m);
     $ratesCached = $processor->getRates($m);
     \XLite\Base::getInstance()->config->Company = $tmpConfig;
     $this->assertTrue(is_array($rates), 'getRates() must return an array (#1)');
     $this->assertEquals(5, count($rates), 'Count of rates is not match with an expected value (#1)');
     $this->assertEquals($rates, $ratesCached, 'Cached rates does not match an original rates (#1)');
     foreach ($rates as $rate) {
         $this->assertTrue($rate instanceof \XLite\Model\Shipping\Rate, 'getRates() must return an array of \\XLite\\Model\\Shipping\\Rate instances (#1)');
         $this->assertTrue($rate->getMethod() instanceof \XLite\Model\Shipping\Method, 'Wrong method object returned (#1)');
         $this->assertEquals('aupost', $rate->getMethod()->getProcessor(), 'Wrong method returned (processor does not match) (#1)');
         $this->assertNotEquals(0, $rate->getBaseRate(), 'Base rate is zero (#1)');
         $this->assertEquals(0, $rate->getMarkupRate(), 'Markup rate is not zero (#1)');
     }
     // Test on an array with input data
     $data = array('weight' => 250, 'srcAddress' => array('zipcode' => 3146), 'dstAddress' => array('zipcode' => '2154', 'country' => 'AU'));
     $rates = $processor->getRates($data, true);
     $this->assertTrue(is_array($rates), 'getRates() must return an array (#2)');
     $this->assertEquals(2, count($rates), 'Count of rates is not match with an expected value (#2)');
     foreach ($rates as $rate) {
         $this->assertTrue($rate instanceof \XLite\Model\Shipping\Rate, 'getRates() must return an array of \\XLite\\Model\\Shipping\\Rate instances (#2)');
         $this->assertTrue($rate->getMethod() instanceof \XLite\Model\Shipping\Method, 'Wrong method object returned (#2)');
         $this->assertEquals('aupost', $rate->getMethod()->getProcessor(), 'Wrong method returned (processor does not match) (#2)');
         $this->assertNotEquals(0, $rate->getBaseRate(), 'Base rate is zero (#2)');
         $this->assertEquals(0, $rate->getMarkupRate(), 'Markup rate is not zero (#2)');
     }
     // Test on anonymous order if config.Company.location_country != 'AU'
     $tmpConfig = \XLite\Base::getInstance()->config->Company;
     \XLite\Base::getInstance()->config->Company->location_country = 'US';
     $m = $this->getTestOrder(false)->getModifier('shipping', 'SHIPPING')->getModifier();
     $rates = $processor->getRates($m);
     \XLite\Base::getInstance()->config->Company = $tmpConfig;
     $this->assertTrue(is_array($rates), 'getRates() must return an array (#3)');
     $this->assertEquals(0, count($rates), 'Count of rates is not match with an expected value (#3)');
 }
Exemplo n.º 7
0
 /**
  * Constructor
  * 
  * @return void
  */
 public function __construct()
 {
     $this->renewChunk(0);
     $this->currentChunkIndex = 0;
     parent::__construct();
 }
Exemplo n.º 8
0
 /**
  * Constructor
  * 
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
 }
Exemplo n.º 9
0
 /**
  * Constructor 
  *
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     $this->response = new \XLite\Module\CDev\XPaymentsConnector\Transport\Response();
 }
Exemplo n.º 10
0
 public static function tearDownAfterClass()
 {
     \XLite\Base::getInstance()->config->Company->users_department = self::$company_email;
     \XLite\Base::getInstance()->config->Company->site_administrator = self::$admin_email;
     self::$admin_profile->setLogin(self::$admin_login);
 }
Exemplo n.º 11
0
Arquivo: USPS.php Projeto: kingsj/core
 /**
  * testGetRates
  *
  * @return void
  * @see    ____func_see____
  * @since  1.0.0
  */
 public function testGetRates()
 {
     if (!isset($this->testConfig['usps'])) {
         $this->markTestSkipped('U.S.P.S tests are not condifured');
     }
     $processor = new XLite\Module\CDev\USPS\Model\Shipping\Processor\USPS();
     \XLite\Base::getInstance()->config->CDev->USPS->userid = $this->testConfig['usps']['userid'];
     // Test on anonymous order
     $tmpConfig = \XLite\Base::getInstance()->config->Company;
     \XLite\Base::getInstance()->config->Company->location_country = 'US';
     \XLite\Base::getInstance()->config->Company->location_zipcode = '10001';
     $m = $this->getTestOrder(false)->getModifier('shipping', 'SHIPPING')->getModifier();
     $rates = $processor->getRates($m, true);
     $ratesCached = $processor->getRates($m);
     \XLite\Base::getInstance()->config->Company = $tmpConfig;
     $this->assertTrue(is_array($rates), 'getRates() must return an array (#1)');
     // Actually USPS returns 22 methods in the response. We check just >15 to avoid failure if USPS will return other number of methods
     $this->assertGreaterThan(15, count($rates), 'Count of rates checking failed (#1) - ' . $processor->getErrorMsg());
     $this->assertEquals($rates, $ratesCached, 'Cached rates does not match an original rates (#1)');
     foreach ($rates as $rate) {
         $this->assertTrue($rate instanceof \XLite\Model\Shipping\Rate, 'getRates() must return an array of \\XLite\\Model\\Shipping\\Rate instances (#1)');
         $this->assertTrue($rate->getMethod() instanceof \XLite\Model\Shipping\Method, 'Wrong method object returned (#1)');
         $this->assertEquals('usps', $rate->getMethod()->getProcessor(), 'Wrong method returned (processor does not match) (#1)');
         $this->assertNotEquals(0, $rate->getBaseRate(), 'Base rate is zero (#1)');
         $this->assertEquals(0, $rate->getMarkupRate(), 'Markup rate is not zero (#1)');
     }
     // Test on an array with input data
     $data = array('srcAddress' => array('zipcode' => 10001), 'dstAddress' => array('zipcode' => '22044', 'country' => 'US'), 'packages' => array(0 => array('weight' => 10, 'subtotal' => 200)));
     $rates = $processor->getRates($data, true);
     $this->assertTrue(is_array($rates), 'getRates() must return an array (#2)');
     $this->assertGreaterThan(15, count($rates), 'Count of rates checking failed (#2) - ' . $processor->getErrorMsg());
     foreach ($rates as $rate) {
         $this->assertTrue($rate instanceof \XLite\Model\Shipping\Rate, 'getRates() must return an array of \\XLite\\Model\\Shipping\\Rate instances (#2)');
         $this->assertTrue($rate->getMethod() instanceof \XLite\Model\Shipping\Method, 'Wrong method object returned (#2)');
         $this->assertEquals('usps', $rate->getMethod()->getProcessor(), 'Wrong method returned (processor does not match) (#2)');
         $this->assertNotEquals(0, $rate->getBaseRate(), 'Base rate is zero (#2)');
         $this->assertEquals(0, $rate->getMarkupRate(), 'Markup rate is not zero (#2)');
     }
     // Test error of Domestic API
     $tmpCont = \XLite\Base::getInstance()->config->CDev->USPS->container;
     \XLite\Base::getInstance()->config->CDev->USPS->container = 'WRONG';
     $rates = $processor->getRates($data, true);
     $this->assertTrue(is_array($rates), 'getRates() must return an array (111)');
     $this->assertEquals(empty($rates), 'getRates() must return empty array (111)');
     \XLite\Base::getInstance()->config->CDev->USPS->container = $tmpCont;
     // Test on anonymous order if config.Company.location_country != 'US'
     $tmpConfig = \XLite\Base::getInstance()->config->Company;
     \XLite\Base::getInstance()->config->Company->location_country = 'AU';
     $m = $this->getTestOrder(false)->getModifier('shipping', 'SHIPPING')->getModifier();
     $rates = $processor->getRates($m, true);
     \XLite\Base::getInstance()->config->Company = $tmpConfig;
     $this->assertTrue(is_array($rates), 'getRates() must return an array (#3)');
     $this->assertEquals(0, count($rates), 'Count of rates is not match with an expected value (#3) - ' . $processor->getErrorMsg());
     unset($rates);
     // Test International API
     \XLite\Base::getInstance()->config->Company->location_country = 'US';
     \XLite\Base::getInstance()->config->CDev->USPS->gxg = true;
     $methodToDelete = 'I-1-735bf98ee9fbdf9dbb374920def99049';
     $method = \XLite\Core\Database::getRepo('XLite\\Model\\Shipping\\Method')->findOneByCode($methodToDelete);
     $this->assertNotNull($method, 'Method with code ' . $methodToDelete . ' not found in the database');
     \XLite\Core\Database::getRepo('XLite\\Model\\Shipping\\Method')->delete($method);
     $method->detach();
     $method = \XLite\Core\Database::getRepo('XLite\\Model\\Shipping\\Method')->findOneByCode($methodToDelete);
     $this->assertNull($method, 'Method with code ' . $methodToDelete . ' found in the database');
     $data = array('srcAddress' => array('zipcode' => 50001), 'dstAddress' => array('zipcode' => '3456', 'country' => 'GB'), 'packages' => array(0 => array('weight' => 3, 'subtotal' => 200)));
     $rates = $processor->getRates($data, true);
     $this->assertTrue(is_array($rates), 'getRates() must return an array (#4)');
     $this->assertGreaterThan(1, count($rates), 'Count of rates checking failed (#4) - ' . $processor->getErrorMsg());
     foreach ($rates as $rate) {
         $this->assertTrue($rate instanceof \XLite\Model\Shipping\Rate, 'getRates() must return an array of \\XLite\\Model\\Shipping\\Rate instances (#4)');
         $this->assertTrue($rate->getMethod() instanceof \XLite\Model\Shipping\Method, 'Wrong method object returned (#4)');
         $this->assertEquals('usps', $rate->getMethod()->getProcessor(), 'Wrong method returned (processor does not match) (#4)');
         $this->assertNotEquals(0, $rate->getBaseRate(), 'Base rate is zero (#4)');
         $this->assertEquals(0, $rate->getMarkupRate(), 'Markup rate is not zero (#4)');
     }
     // Check that method I-1 returned to the database
     $method = \XLite\Core\Database::getRepo('XLite\\Model\\Shipping\\Method')->findOneByCode($methodToDelete);
     $this->assertNotNull($method, 'Method with code ' . $methodToDelete . ' not restored in the database after request to USPS');
     $this->assertFalse($method->getEnabled(), 'Method with code ' . $methodToDelete . ' restored with enabled status');
     // Test International API error
     \XLite\Base::getInstance()->config->CDev->USPS->mail_type = 'WRONG';
     \XLite\Base::getInstance()->config->CDev->USPS->gxg = false;
     $rates = $processor->getRates($data, true);
     $this->assertTrue(is_array($rates), 'getRates() must return an array (222)');
     $this->assertEquals(empty($rates), 'getRates() must return empty array (222)');
     // Test for wrong input data
     $data = array('something' => 'wrong');
     $rates = $processor->getRates($data, true);
     $this->assertTrue(is_array($rates), 'getRates() must return an array (333)');
     $this->assertEquals(empty($rates), 'getRates() must return empty array (333)');
 }