Ejemplo n.º 1
0
 /**
  * Make sure that we can retrieve all of the subdivisions.
  *
  * In addition to being able to retrieve all subdivisions, we should also
  * be able to retrieve all subdivisions of a specific country. If there are
  * no subdivisions available, an empty array should be returned.
  */
 public function testLoadSubdivisions()
 {
     $subdivisions = $this->loader->loadSubdivisions();
     $this->assertCount(3771, $subdivisions, 'All parent subdivisions should be returned.');
     $this->checkSubdivision($subdivisions['US-CA']);
     $subdivisions = $this->loader->loadSubdivisions('US');
     $this->assertCount(57, $subdivisions, 'Only the subdivisions for "US" should be returned.');
     $this->checkSubdivision($subdivisions['US-CA']);
 }
Ejemplo n.º 2
0
 /**
  * @param string $countryCode
  * @return array
  */
 private function getStates($countryCode)
 {
     if ($countryCode === NULL) {
         return array();
     }
     if (!in_array($countryCode, $this->countriesWithStates)) {
         return NULL;
     } else {
         $subdivisions = $this->loader->loadSubdivisions($countryCode);
         $pairs = array(NULL => '- select state -');
         /** @var Subdivision $subdivision */
         foreach ($subdivisions as $subdivision) {
             $parts = explode('-', $subdivision->getCode());
             $pairs[$parts[1]] = $subdivision->getName();
         }
         return $pairs;
     }
 }