/** * @return array */ private function getCountries() { if (!$this->defaultCountryCode) { $pairs = array(NULL => '- select country -'); } if ($this->allowedCountries === self::ALL) { /** @var Country $country */ foreach ($this->loader->loadCountries() as $country) { $pairs[$country->getAlpha2Code()] = $country->getShortName(); } } else { foreach ($this->allowedCountries as $countryCode) { $country = $this->loader->loadCountry($countryCode); $pairs[$country->getAlpha2Code()] = $country->getShortName(); } } return $pairs; }
/** * Make sure that an exception is thrown if we cannot load an XML file. */ public function testLoadFail() { $loader = new Loader('/does/not/exist.xml'); $this->setExpectedException('Phine\\Country\\Exception\\XmlException', 'failed to load external entity'); $loader->loadCountries(); }