X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fmaintenance%2Fbackup_PageTest.php;h=0cb0cdb65d4e722951e3e7c98c9892fcdbd4f23d;hb=1834ee3d8e2f6a8ef2067ee7925c4f561209b12f;hp=69636010ede1d80c2d0846bcb7e7d254e0dd47bf;hpb=4856e2cba138d14a4354f95b5fcff05d63b00228;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/maintenance/backup_PageTest.php b/tests/phpunit/maintenance/backup_PageTest.php index 69636010ed..a07e62c9b8 100644 --- a/tests/phpunit/maintenance/backup_PageTest.php +++ b/tests/phpunit/maintenance/backup_PageTest.php @@ -6,6 +6,7 @@ * @group Dump * @covers BackupDumper */ + class BackupDumperPageTest extends DumpTestCase { // We'll add several pages, revision and texts. The following variables hold the @@ -21,10 +22,10 @@ class BackupDumperPageTest extends DumpTestCase { function addDBData() { // be sure, titles created here using english namespace names - $this->setMwGlobals( array( + $this->setMwGlobals( [ 'wgLanguageCode' => 'en', 'wgContLang' => Language::factory( 'en' ), - ) ); + ] ); $this->tablesUsed[] = 'page'; $this->tablesUsed[] = 'revision'; @@ -90,22 +91,23 @@ class BackupDumperPageTest extends DumpTestCase { // class), we have to assert, that the page id are consecutively // increasing $this->assertEquals( - array( $this->pageId2, $this->pageId3, $this->pageId4 ), - array( $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ), + [ $this->pageId2, $this->pageId3, $this->pageId4 ], + [ $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ], "Page ids increasing without holes" ); } function testFullTextPlain() { // Preparing the dump $fname = $this->getNewTempFile(); - $dumper = new BackupDumper( array( "--output=file:" . $fname ) ); + + $dumper = new DumpBackup(); + $dumper->loadWithArgv( [ '--full', '--quiet', '--output', 'file:' . $fname ] ); $dumper->startId = $this->pageId1; $dumper->endId = $this->pageId4 + 1; - $dumper->reporting = false; - $dumper->setDb( $this->db ); + $dumper->setDB( $this->db ); // Performing the dump - $dumper->dump( WikiExporter::FULL, WikiExporter::TEXT ); + $dumper->execute(); // Checking the dumped data $this->assertDumpStart( $fname ); @@ -137,7 +139,11 @@ class BackupDumperPageTest extends DumpTestCase { // -> Page is marked deleted. Hence not visible // Page 4 - $this->assertPageStart( $this->pageId4, $this->talk_namespace, $this->pageTitle4->getPrefixedText() ); + $this->assertPageStart( + $this->pageId4, + $this->talk_namespace, + $this->pageTitle4->getPrefixedText() + ); $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1", $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe", "Talk about BackupDumperTestP1 Text1" ); @@ -149,14 +155,15 @@ class BackupDumperPageTest extends DumpTestCase { function testFullStubPlain() { // Preparing the dump $fname = $this->getNewTempFile(); - $dumper = new BackupDumper( array( "--output=file:" . $fname ) ); + + $dumper = new DumpBackup(); + $dumper->loadWithArgv( [ '--full', '--quiet', '--output', 'file:' . $fname, '--stub' ] ); $dumper->startId = $this->pageId1; $dumper->endId = $this->pageId4 + 1; - $dumper->reporting = false; $dumper->setDb( $this->db ); // Performing the dump - $dumper->dump( WikiExporter::FULL, WikiExporter::STUB ); + $dumper->execute(); // Checking the dumped data $this->assertDumpStart( $fname ); @@ -183,7 +190,11 @@ class BackupDumperPageTest extends DumpTestCase { // -> Page is marked deleted. Hence not visible // Page 4 - $this->assertPageStart( $this->pageId4, $this->talk_namespace, $this->pageTitle4->getPrefixedText() ); + $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(); @@ -194,7 +205,8 @@ class BackupDumperPageTest extends DumpTestCase { function testCurrentStubPlain() { // Preparing the dump $fname = $this->getNewTempFile(); - $dumper = new BackupDumper( array( "--output=file:" . $fname ) ); + + $dumper = new DumpBackup( [ '--output', 'file:' . $fname ] ); $dumper->startId = $this->pageId1; $dumper->endId = $this->pageId4 + 1; $dumper->reporting = false; @@ -222,7 +234,11 @@ class BackupDumperPageTest extends DumpTestCase { // -> Page is marked deleted. Hence not visible // Page 4 - $this->assertPageStart( $this->pageId4, $this->talk_namespace, $this->pageTitle4->getPrefixedText() ); + $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(); @@ -235,7 +251,8 @@ class BackupDumperPageTest extends DumpTestCase { // Preparing the dump $fname = $this->getNewTempFile(); - $dumper = new BackupDumper( array( "--output=gzip:" . $fname ) ); + + $dumper = new DumpBackup( [ '--output', 'gzip:' . $fname ] ); $dumper->startId = $this->pageId1; $dumper->endId = $this->pageId4 + 1; $dumper->reporting = false; @@ -264,7 +281,11 @@ class BackupDumperPageTest extends DumpTestCase { // -> Page is marked deleted. Hence not visible // Page 4 - $this->assertPageStart( $this->pageId4, $this->talk_namespace, $this->pageTitle4->getPrefixedText() ); + $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(); @@ -272,28 +293,29 @@ class BackupDumperPageTest extends DumpTestCase { $this->assertDumpEnd(); } + /** + * xmldumps-backup typically performs a single dump that that writes + * out three files + * - gzipped stubs of everything (meta-history) + * - gzipped stubs of latest revisions of all pages (meta-current) + * - gzipped stubs of latest revisions of all pages of namespage 0 + * (articles) + * + * We reproduce such a setup with our mini fixture, although we omit + * chunks, and all the other gimmicks of xmldumps-backup. + */ function testXmlDumpsBackupUseCase() { - // xmldumps-backup typically performs a single dump that that writes - // out three files - // * gzipped stubs of everything (meta-history) - // * gzipped stubs of latest revisions of all pages (meta-current) - // * gzipped stubs of latest revisions of all pages of namespage 0 - // (articles) - // - // We reproduce such a setup with our mini fixture, although we omit - // chunks, and all the other gimmicks of xmldumps-backup. - // $this->checkHasGzip(); $fnameMetaHistory = $this->getNewTempFile(); $fnameMetaCurrent = $this->getNewTempFile(); $fnameArticles = $this->getNewTempFile(); - $dumper = new BackupDumper( array( "--output=gzip:" . $fnameMetaHistory, + $dumper = new DumpBackup( [ "--full", "--stub", "--output=gzip:" . $fnameMetaHistory, "--output=gzip:" . $fnameMetaCurrent, "--filter=latest", "--output=gzip:" . $fnameArticles, "--filter=latest", "--filter=notalk", "--filter=namespace:!NS_USER", - "--reporting=1000" ) ); + "--reporting=1000" ] ); $dumper->startId = $this->pageId1; $dumper->endId = $this->pageId4 + 1; $dumper->setDb( $this->db ); @@ -339,7 +361,11 @@ class BackupDumperPageTest extends DumpTestCase { // -> Page is marked deleted. Hence not visible // Page 4 - $this->assertPageStart( $this->pageId4, $this->talk_namespace, $this->pageTitle4->getPrefixedText() ); + $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(); @@ -367,7 +393,11 @@ class BackupDumperPageTest extends DumpTestCase { // -> Page is marked deleted. Hence not visible // Page 4 - $this->assertPageStart( $this->pageId4, $this->talk_namespace, $this->pageTitle4->getPrefixedText() ); + $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();