예제 #1
0
파일: Address.php 프로젝트: kingsj/core
 /**
  * testGetState
  *
  * @return void
  * @access public
  * @see    ____func_see____
  * @since  1.0.0
  */
 public function testGetState()
 {
     $address = new \XLite\Model\Address();
     $address->map($this->addressFields);
     $address->setCountry(\XLite\Core\Database::getRepo('XLite\\Model\\Country')->find('US'));
     $address->setState(\XLite\Core\Database::getRepo('XLite\\Model\\State')->findOneByCountryAndCode('US', 'NY'));
     $this->assertInstanceOf('\\XLite\\Model\\State', $address->getState(), 'State checking');
     $address->setState('Test state');
     $this->assertInstanceOf('\\XLite\\Model\\State', $address->getState(), 'State checking #2');
     $this->assertEquals('Test state', $address->getState()->getState(), 'State name checking');
     $this->assertNull($address->getState()->getStateId(), 'State id checking');
     $s = new \XLite\Model\State();
     $s->setState('Test state 2');
     $address->setState($s);
     $this->assertInstanceOf('\\XLite\\Model\\State', $address->getState(), 'State checking #3');
     $this->assertEquals('Test state 2', $address->getState()->getState(), 'State name checking #3');
     $this->assertNull($address->getState()->getStateId(), 'State id checking #3');
     $address->setCustomState('Test state 3');
     $this->assertInstanceOf('\\XLite\\Model\\State', $address->getState(), 'State checking #4');
     $this->assertEquals('Test state 3', $address->getState()->getState(), 'State name checking #4');
     $this->assertNull($address->getState()->getStateId(), 'State id checking #4');
 }
예제 #2
0
파일: Order.php 프로젝트: kirkbauer2/kirkxc
 /**
  * Returns delivery source address
  *
  * @return \XLite\Model\Address
  */
 public function getSourceAddress()
 {
     if (null === $this->sourceAddress) {
         $address = new \XLite\Model\Address();
         $config = $this->getCompanyConfiguration();
         $address->setStreet($config->location_address);
         $address->setCity($config->location_city);
         $address->setCountryCode($config->location_country);
         if ($config->location_state) {
             $address->setStateId($config->location_state);
         }
         if ($config->location_custom_state) {
             $address->setCustomState($config->location_custom_state);
         }
         $address->setZipcode($config->location_zipcode);
         $this->sourceAddress = $address;
     }
     return $this->sourceAddress;
 }