function testFullStubPlain() { // Preparing the dump $fname = $this->getNewTempFile(); $dumper = new DumpBackup(); $dumper->loadWithArgv(['--full', '--quiet', '--output', 'file:' . $fname, '--stub']); $dumper->startId = $this->pageId1; $dumper->endId = $this->pageId4 + 1; $dumper->setDB($this->db); // Performing the dump $dumper->execute(); // Checking the dumped data $this->assertDumpStart($fname); // Page 1 $this->assertPageStart($this->pageId1, $this->namespace, $this->pageTitle1->getPrefixedText()); $this->assertRevision($this->revId1_1, "BackupDumperTestP1Summary1", $this->textId1_1, 23, "0bolhl6ol7i6x0e7yq91gxgaan39j87"); $this->assertPageEnd(); // Page 2 $this->assertPageStart($this->pageId2, $this->namespace, $this->pageTitle2->getPrefixedText()); $this->assertRevision($this->revId2_1, "BackupDumperTestP2Summary1", $this->textId2_1, 23, "jprywrymfhysqllua29tj3sc7z39dl2"); $this->assertRevision($this->revId2_2, "BackupDumperTestP2Summary2", $this->textId2_2, 23, "b7vj5ks32po5m1z1t1br4o7scdwwy95", false, $this->revId2_1); $this->assertRevision($this->revId2_3, "BackupDumperTestP2Summary3", $this->textId2_3, 23, "jfunqmh1ssfb8rs43r19w98k28gg56r", false, $this->revId2_2); $this->assertRevision($this->revId2_4, "BackupDumperTestP2Summary4 extra", $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv", false, $this->revId2_3); $this->assertPageEnd(); // Page 3 // -> Page is marked deleted. Hence not visible // Page 4 $this->assertPageStart($this->pageId4, $this->talk_namespace, $this->pageTitle4->getPrefixedText()); $this->assertRevision($this->revId4_1, "Talk BackupDumperTestP1 Summary1", $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe"); $this->assertPageEnd(); $this->assertDumpEnd(); }
function testXmlDumpsBackupUseCaseLogging() { global $wgContLang; $this->checkHasGzip(); // Preparing the dump $fname = $this->getNewTempFile(); $dumper = new DumpBackup(); $dumper->loadWithArgv(['--logs', '--output=gzip:' . $fname, '--reporting=2']); $dumper->startId = $this->logId1; $dumper->endId = $this->logId3 + 1; $dumper->setDB($this->db); // xmldumps-backup demands reporting, although this is currently not // implemented in BackupDumper, when dumping logging data. We // nevertheless capture the output of the dump process already now, // to be able to alert (once dumping produces reports) that this test // needs updates. $dumper->stderr = fopen('php://output', 'a'); if ($dumper->stderr === false) { $this->fail("Could not open stream for stderr"); } // Performing the dump $dumper->execute(); $this->assertTrue(fclose($dumper->stderr), "Closing stderr handle"); // Analyzing the dumped data $this->gunzip($fname); $this->assertDumpStart($fname); $this->assertLogItem($this->logId1, "BackupDumperLogUserA", $this->userId1, null, "type", "subtype", "PageA"); $this->assertNotNull($wgContLang, "Content language object validation"); $namespace = $wgContLang->getNsText(NS_TALK); $this->assertInternalType('string', $namespace); $this->assertGreaterThan(0, strlen($namespace)); $this->assertLogItem($this->logId2, "BackupDumperLogUserB", $this->userId2, "SomeComment", "supress", "delete", $namespace . ":PageB"); $this->assertLogItem($this->logId3, "BackupDumperLogUserB", $this->userId2, "SomeOtherComment", "move", "delete", "PageA", ['key1' => 1, 3 => 'value3']); $this->assertDumpEnd(); // Currently, no reporting is implemented. Alert via failure, once // this changes. // If reporting for log dumps has been implemented, please update // the following statement to catch good output $this->expectOutputString(''); }