Example #1
0
 public function testImportFromXML_malformed()
 {
     $this->setExpectedException('Exception');
     $store = $this->getMock('SiteStore');
     $importer = new SiteImporter($store);
     $importer->importFromXML('THIS IS NOT XML');
 }
 /**
  * Do the import.
  */
 public function execute()
 {
     $file = $this->getArg(0);
     $importer = new SiteImporter(SiteSQLStore::newInstance());
     $importer->setExceptionCallback(array($this, 'reportException'));
     $importer->importFromFile($file);
     $this->output("Done.\n");
 }
Example #3
0
 /**
  * Do the import.
  */
 public function execute()
 {
     $file = $this->getArg(0);
     $siteStore = \MediaWiki\MediaWikiServices::getInstance()->getSiteStore();
     $importer = new SiteImporter($siteStore);
     $importer->setExceptionCallback([$this, 'reportException']);
     $importer->importFromFile($file);
     $this->output("Done.\n");
 }
 /**
  * @dataProvider provideRoundTrip()
  */
 public function testRoundTrip(SiteList $sites)
 {
     $tmp = tmpfile();
     $exporter = new SiteExporter($tmp);
     $exporter->exportSites($sites);
     fseek($tmp, 0);
     $xml = fread($tmp, 16 * 1024);
     $actualSites = new SiteList();
     $store = $this->newSiteStore($actualSites);
     $importer = new SiteImporter($store);
     $importer->importFromXML($xml);
     $this->assertEquals($sites, $actualSites);
 }