/**
  * Test dependancy
  */
 public function testCountriesAreLoadedFromDisk()
 {
     $conf = new AppConf();
     if (!file_exists($conf->getLocalCopySite())) {
         $html = SourceLoad::open(new URL(AppConf::ZEND_SITE_URL));
         SourceStore::save($conf->getLocalCopySite(), $html);
     }
     $htmlLoc = SourceLoad::open(new File($conf->getLocalCopySite()));
     $this->assertInstanceOf("ZendDirectoryInfo\\Source\\HtmlSource", $htmlLoc);
     $html = SourceLoad::open(new URL(AppConf::ZEND_SITE_URL));
     $zendCountries = new ZendCountries($html, $conf);
     $zendCountries->extract();
     $this->assertNotEmpty($zendCountries);
     $data = $zendCountries->getData();
     $this->assertArrayHasKey("Malta", $data);
     $this->assertEquals(135, $data["Malta"]);
 }
 /**
  * Test Code to bypass country code extraction
  */
 public function testCountryCodeStorageCached()
 {
     $conf = new AppConf();
     $html = SourceLoad::open(new URL(AppConf::ZEND_SITE_URL));
     $zendCountries = new ZendCountries($html, $conf);
     if (is_file($conf->getZendCountriesPath())) {
         $data = file_get_contents($conf->getZendCountriesPath());
         $zendCountries = unserialize($data);
         $data = $zendCountries->getData();
         $this->assertArrayHasKey("Malta", $data);
         $this->assertEquals(135, $data["Malta"]);
         $this->assertNotEmpty($zendCountries);
     } else {
         // No file means Get Fresh Data and rerun
         $zendCountries->extract();
         $this->assertNotEmpty($zendCountries);
         $data = $zendCountries->getData();
         $this->assertArrayHasKey("Malta", $data);
         $this->assertEquals(135, $data["Malta"]);
         file_put_contents($conf->getZendCountriesPath(), serialize($zendCountries));
         $this->assertNotEmpty(unserialize(file_get_contents($conf->getZendCountriesPath())));
     }
 }
 /**
  * @param $source
  * @throws \Exception
  * @dataProvider xmlProvider
  */
 function testSourceIsNotSupported(\ZendDirectoryInfo\DataAccess\Location $source)
 {
     $this->setExpectedException('\\InvalidArgumentException');
     SourceLoad::open($source);
 }