Example #1
0
 public function testHasRegions()
 {
     $country = new Country('iso2Code');
     $region = new Region('combinedCode');
     $this->assertFalse($country->hasRegions());
     $country->addRegion($region);
     $this->assertTrue($country->hasRegions());
 }
 /**
  * @param string $locale
  * @param array $countryData
  * @return null|Country
  */
 protected function getCountry($locale, array $countryData)
 {
     if (empty($countryData['iso2Code']) || empty($countryData['iso3Code'])) {
         return null;
     }
     /** @var $country Country */
     $country = $this->countryRepository->findOneBy(array('iso2Code' => $countryData['iso2Code']));
     if (!$country) {
         $country = new Country($countryData['iso2Code']);
         $country->setIso3Code($countryData['iso3Code']);
     }
     $countryName = $this->translate($countryData['iso2Code'], static::COUNTRY_PREFIX, $locale);
     $country->setLocale($locale)->setName($countryName);
     return $country;
 }
 public function setUp()
 {
     $this->channel = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Entity\\Channel');
     $this->customer = $this->getMock('OroCRM\\Bundle\\MagentoBundle\\Entity\\Customer');
     $this->contact = $this->getMock('OroCRM\\Bundle\\ContactBundle\\Entity\\Contact');
     $this->address = $this->getMock('OroCRM\\Bundle\\MagentoBundle\\Entity\\Address');
     $this->contactAddress = $this->getMock('OroCRM\\Bundle\\ContactBundle\\Entity\\ContactAddress');
     $this->contactPhone = $this->getMock('OroCRM\\Bundle\\ContactBundle\\Entity\\ContactPhone');
     $this->country = $this->getMockBuilder('Oro\\Bundle\\AddressBundle\\Entity\\Country')->disableOriginalConstructor()->getMock();
     $this->region = $this->getMockBuilder('Oro\\Bundle\\AddressBundle\\Entity\\Region')->disableOriginalConstructor()->getMock();
     $collection = $this->getMock('Doctrine\\Common\\Collections\\Collection');
     $collection->expects($this->any())->method('getValues')->will($this->returnValue([$this->address]));
     $this->country->expects($this->any())->method('getIso2Code')->will($this->returnValue('US'));
     $this->region->expects($this->any())->method('getCombinedCode')->will($this->returnValue('US-US'));
     $this->contactAddress->expects($this->any())->method('getCountry')->will($this->returnValue($this->country));
     $this->contactAddress->expects($this->any())->method('getRegion')->will($this->returnValue($this->region));
     $this->customer->expects($this->any())->method('getContact')->will($this->returnValue($this->contact));
     $this->customer->expects($this->any())->method('getChannel')->will($this->returnValue($this->channel));
     $this->address->expects($this->any())->method('getContactAddress')->will($this->returnValue($this->contactAddress));
     $this->address->expects($this->any())->method('getContactPhone')->will($this->returnValue($this->contactPhone));
     $this->address->expects($this->any())->method('getCountry')->will($this->returnValue($this->country));
     $this->address->expects($this->any())->method('getRegion')->will($this->returnValue($this->region));
     $this->customer->expects($this->any())->method('getAddresses')->will($this->returnValue($collection));
 }
Example #4
0
 /**
  * Get country ISO2 code
  *
  * @return Country
  */
 public function getCountryIso2Code()
 {
     return $this->country ? $this->country->getIso2Code() : null;
 }
 /**
  * @param string $code
  * @param Country $country
  * @return Region
  */
 protected function createRegion($code, Country $country)
 {
     $result = new Region($country->getIso2Code() . '.' . $code);
     $result->setCode($code);
     return $result;
 }