/** * 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"); }
/** * 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"); }
private function newSiteImporter(array $expectedSites, $errorCount) { $store = $this->getMock('SiteStore'); $store->expects($this->once())->method('saveSites')->will($this->returnCallback(function ($sites) use($expectedSites) { $this->assertSitesEqual($expectedSites, $sites); })); $store->expects($this->any())->method('getSites')->will($this->returnValue(new SiteList())); $errorHandler = $this->getMock('Psr\\Log\\LoggerInterface'); $errorHandler->expects($this->exactly($errorCount))->method('error'); $importer = new SiteImporter($store); $importer->setExceptionCallback(array($errorHandler, 'error')); return $importer; }