X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fmaintenance%2FbackupTextPassTest.php;h=e059834e29193f72c1c80592cacb11624c73552c;hb=a88f1d6b58613cbfa5c24c97887197a41ce66908;hp=b8a60bec39ff2c619eea403e7906eaecc5dd5ff8;hpb=66351c7f1bb0e402bcfe233a3fa94df55ffec007;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/maintenance/backupTextPassTest.php b/tests/phpunit/maintenance/backupTextPassTest.php index b8a60bec39..e059834e29 100644 --- a/tests/phpunit/maintenance/backupTextPassTest.php +++ b/tests/phpunit/maintenance/backupTextPassTest.php @@ -11,8 +11,6 @@ use Title; use WikiExporter; use WikiPage; -require_once __DIR__ . "/../../../maintenance/dumpTextPass.php"; - /** * Tests for TextPassDumper that rely on the database * @@ -132,45 +130,46 @@ class TextPassDumperDatabaseTest extends DumpTestCase { $dumper->dump( WikiExporter::FULL, WikiExporter::TEXT ); // Checking for correctness of the dumped data - $this->assertDumpStart( $nameFull ); + $asserter = $this->getDumpAsserter(); + $asserter->assertDumpStart( $nameFull ); // Page 1 - $this->assertPageStart( $this->pageId1, NS_MAIN, "BackupDumperTestP1" ); - $this->assertRevision( $this->revId1_1, "BackupDumperTestP1Summary1", + $asserter->assertPageStart( $this->pageId1, NS_MAIN, "BackupDumperTestP1" ); + $asserter->assertRevision( $this->revId1_1, "BackupDumperTestP1Summary1", $this->textId1_1, false, "0bolhl6ol7i6x0e7yq91gxgaan39j87", "BackupDumperTestP1Text1" ); - $this->assertPageEnd(); + $asserter->assertPageEnd(); // Page 2 - $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" ); - $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1", + $asserter->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" ); + $asserter->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1", $this->textId2_1, false, "jprywrymfhysqllua29tj3sc7z39dl2", "BackupDumperTestP2Text1" ); - $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2", + $asserter->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2", $this->textId2_2, false, "b7vj5ks32po5m1z1t1br4o7scdwwy95", "BackupDumperTestP2Text2", $this->revId2_1 ); - $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3", + $asserter->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3", $this->textId2_3, false, "jfunqmh1ssfb8rs43r19w98k28gg56r", "BackupDumperTestP2Text3", $this->revId2_2 ); - $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra", + $asserter->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra", $this->textId2_4, false, "6o1ciaxa6pybnqprmungwofc4lv00wv", "BackupDumperTestP2Text4 some additional Text", $this->revId2_3 ); - $this->assertPageEnd(); + $asserter->assertPageEnd(); // Page 3 // -> Page is marked deleted. Hence not visible // Page 4 - $this->assertPageStart( $this->pageId4, NS_TALK, "Talk:BackupDumperTestP1" ); - $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1", + $asserter->assertPageStart( $this->pageId4, NS_TALK, "Talk:BackupDumperTestP1" ); + $asserter->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1", $this->textId4_1, false, "nktofwzd0tl192k3zfepmlzxoax1lpe", "TALK ABOUT BACKUPDUMPERTESTP1 TEXT1", false, "BackupTextPassTestModel", "text/plain" ); - $this->assertPageEnd(); + $asserter->assertPageEnd(); - $this->assertDumpEnd(); + $asserter->assertDumpEnd(); } function testPrefetchPlain() { @@ -204,49 +203,50 @@ class TextPassDumperDatabaseTest extends DumpTestCase { $dumper->dump( WikiExporter::FULL, WikiExporter::TEXT ); // Checking for correctness of the dumped data - $this->assertDumpStart( $nameFull ); + $asserter = $this->getDumpAsserter(); + $asserter->assertDumpStart( $nameFull ); // Page 1 - $this->assertPageStart( $this->pageId1, NS_MAIN, "BackupDumperTestP1" ); + $asserter->assertPageStart( $this->pageId1, NS_MAIN, "BackupDumperTestP1" ); // Prefetch kicks in. This is still the SHA-1 of the original text, // But the actual text (with different SHA-1) comes from prefetch. - $this->assertRevision( $this->revId1_1, "BackupDumperTestP1Summary1", + $asserter->assertRevision( $this->revId1_1, "BackupDumperTestP1Summary1", $this->textId1_1, false, "0bolhl6ol7i6x0e7yq91gxgaan39j87", "Prefetch_________1Text1" ); - $this->assertPageEnd(); + $asserter->assertPageEnd(); // Page 2 - $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" ); - $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1", + $asserter->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" ); + $asserter->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1", $this->textId2_1, false, "jprywrymfhysqllua29tj3sc7z39dl2", "BackupDumperTestP2Text1" ); - $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2", + $asserter->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2", $this->textId2_2, false, "b7vj5ks32po5m1z1t1br4o7scdwwy95", "BackupDumperTestP2Text2", $this->revId2_1 ); // Prefetch kicks in. This is still the SHA-1 of the original text, // But the actual text (with different SHA-1) comes from prefetch. - $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3", + $asserter->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3", $this->textId2_3, false, "jfunqmh1ssfb8rs43r19w98k28gg56r", "Prefetch_________2Text3", $this->revId2_2 ); - $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra", + $asserter->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra", $this->textId2_4, false, "6o1ciaxa6pybnqprmungwofc4lv00wv", "BackupDumperTestP2Text4 some additional Text", $this->revId2_3 ); - $this->assertPageEnd(); + $asserter->assertPageEnd(); // Page 3 // -> Page is marked deleted. Hence not visible // Page 4 - $this->assertPageStart( $this->pageId4, NS_TALK, "Talk:BackupDumperTestP1" ); - $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1", + $asserter->assertPageStart( $this->pageId4, NS_TALK, "Talk:BackupDumperTestP1" ); + $asserter->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1", $this->textId4_1, false, "nktofwzd0tl192k3zfepmlzxoax1lpe", "TALK ABOUT BACKUPDUMPERTESTP1 TEXT1", false, "BackupTextPassTestModel", "text/plain" ); - $this->assertPageEnd(); + $asserter->assertPageEnd(); - $this->assertDumpEnd(); + $asserter->assertDumpEnd(); } /** @@ -331,6 +331,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { $lookingForPage = 1; $checkpointFiles = 0; + $asserter = $this->getDumpAsserter(); + // Each run of the following loop body tries to handle exactly 1 /page/ (not // iteration of stub content). $i is only increased after having treated page 4. for ( $i = 0; $i < $iterations; ) { @@ -348,7 +350,7 @@ class TextPassDumperDatabaseTest extends DumpTestCase { if ( $checkpointFormat == "gzip" ) { $this->gunzip( $nameOutputDir . "/" . $fname ); } - $this->assertDumpStart( $nameOutputDir . "/" . $fname ); + $asserter->assertDumpStart( $nameOutputDir . "/" . $fname ); $fileOpened = true; $checkpointFiles++; } @@ -357,51 +359,90 @@ class TextPassDumperDatabaseTest extends DumpTestCase { switch ( $lookingForPage ) { case 1: // Page 1 - $this->assertPageStart( $this->pageId1 + $i * self::$numOfPages, NS_MAIN, - "BackupDumperTestP1" ); - $this->assertRevision( $this->revId1_1 + $i * self::$numOfRevs, "BackupDumperTestP1Summary1", - $this->textId1_1, false, "0bolhl6ol7i6x0e7yq91gxgaan39j87", - "BackupDumperTestP1Text1" ); - $this->assertPageEnd(); + $asserter->assertPageStart( + $this->pageId1 + $i * self::$numOfPages, + NS_MAIN, + "BackupDumperTestP1" + ); + $asserter->assertRevision( + $this->revId1_1 + $i * self::$numOfRevs, + "BackupDumperTestP1Summary1", + $this->textId1_1, + false, + "0bolhl6ol7i6x0e7yq91gxgaan39j87", + "BackupDumperTestP1Text1" + ); + $asserter->assertPageEnd(); $lookingForPage = 2; break; case 2: // Page 2 - $this->assertPageStart( $this->pageId2 + $i * self::$numOfPages, NS_MAIN, - "BackupDumperTestP2" ); - $this->assertRevision( $this->revId2_1 + $i * self::$numOfRevs, "BackupDumperTestP2Summary1", - $this->textId2_1, false, "jprywrymfhysqllua29tj3sc7z39dl2", - "BackupDumperTestP2Text1" ); - $this->assertRevision( $this->revId2_2 + $i * self::$numOfRevs, "BackupDumperTestP2Summary2", - $this->textId2_2, false, "b7vj5ks32po5m1z1t1br4o7scdwwy95", - "BackupDumperTestP2Text2", $this->revId2_1 + $i * self::$numOfRevs ); - $this->assertRevision( $this->revId2_3 + $i * self::$numOfRevs, "BackupDumperTestP2Summary3", - $this->textId2_3, false, "jfunqmh1ssfb8rs43r19w98k28gg56r", - "BackupDumperTestP2Text3", $this->revId2_2 + $i * self::$numOfRevs ); - $this->assertRevision( $this->revId2_4 + $i * self::$numOfRevs, + $asserter->assertPageStart( + $this->pageId2 + $i * self::$numOfPages, + NS_MAIN, + "BackupDumperTestP2" + ); + $asserter->assertRevision( + $this->revId2_1 + $i * self::$numOfRevs, + "BackupDumperTestP2Summary1", + $this->textId2_1, + false, + "jprywrymfhysqllua29tj3sc7z39dl2", + "BackupDumperTestP2Text1" + ); + $asserter->assertRevision( + $this->revId2_2 + $i * self::$numOfRevs, + "BackupDumperTestP2Summary2", + $this->textId2_2, + false, + "b7vj5ks32po5m1z1t1br4o7scdwwy95", + "BackupDumperTestP2Text2", + $this->revId2_1 + $i * self::$numOfRevs + ); + $asserter->assertRevision( + $this->revId2_3 + $i * self::$numOfRevs, + "BackupDumperTestP2Summary3", + $this->textId2_3, + false, + "jfunqmh1ssfb8rs43r19w98k28gg56r", + "BackupDumperTestP2Text3", + $this->revId2_2 + $i * self::$numOfRevs + ); + $asserter->assertRevision( + $this->revId2_4 + $i * self::$numOfRevs, "BackupDumperTestP2Summary4 extra", - $this->textId2_4, false, "6o1ciaxa6pybnqprmungwofc4lv00wv", + $this->textId2_4, + false, + "6o1ciaxa6pybnqprmungwofc4lv00wv", "BackupDumperTestP2Text4 some additional Text", - $this->revId2_3 + $i * self::$numOfRevs ); - $this->assertPageEnd(); + $this->revId2_3 + $i * self::$numOfRevs + ); + $asserter->assertPageEnd(); $lookingForPage = 4; break; case 4: // Page 4 - $this->assertPageStart( $this->pageId4 + $i * self::$numOfPages, NS_TALK, - "Talk:BackupDumperTestP1" ); - $this->assertRevision( $this->revId4_1 + $i * self::$numOfRevs, + $asserter->assertPageStart( + $this->pageId4 + $i * self::$numOfPages, + NS_TALK, + "Talk:BackupDumperTestP1" + ); + $asserter->assertRevision( + $this->revId4_1 + $i * self::$numOfRevs, "Talk BackupDumperTestP1 Summary1", - $this->textId4_1, false, "nktofwzd0tl192k3zfepmlzxoax1lpe", + $this->textId4_1, + false, + "nktofwzd0tl192k3zfepmlzxoax1lpe", "TALK ABOUT BACKUPDUMPERTESTP1 TEXT1", false, "BackupTextPassTestModel", - "text/plain" ); - $this->assertPageEnd(); + "text/plain" + ); + $asserter->assertPageEnd(); $lookingForPage = 1; @@ -417,7 +458,7 @@ class TextPassDumperDatabaseTest extends DumpTestCase { if ( $this->xml->nodeType == XMLReader::END_ELEMENT && $this->xml->name == "mediawiki" ) { - $this->assertDumpEnd(); + $asserter->assertDumpEnd(); $fileOpened = false; } } @@ -520,6 +561,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { $content = $header; $iterations = intval( $iterations ); + $username = $this->getTestUser()->getUser()->getName(); + $userid = $this->getTestUser()->getUser()->getId(); for ( $i = 0; $i < $iterations; $i++ ) { $page1 = ' BackupDumperTestP1 @@ -529,7 +572,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { ' . ( $this->revId1_1 + $i * self::$numOfRevs ) . ' 2012-04-01T16:46:05Z - 127.0.0.1 + ' . $username . ' + ' . $userid . ' BackupDumperTestP1Summary1 wikitext @@ -547,7 +591,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { ' . ( $this->revId2_1 + $i * self::$numOfRevs ) . ' 2012-04-01T16:46:05Z - 127.0.0.1 + ' . $username . ' + ' . $userid . ' BackupDumperTestP2Summary1 wikitext @@ -560,7 +605,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { ' . ( $this->revId2_1 + $i * self::$numOfRevs ) . ' 2012-04-01T16:46:05Z - 127.0.0.1 + ' . $username . ' + ' . $userid . ' BackupDumperTestP2Summary2 wikitext @@ -573,7 +619,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { ' . ( $this->revId2_2 + $i * self::$numOfRevs ) . ' 2012-04-01T16:46:05Z - 127.0.0.1 + ' . $username . ' + ' . $userid . ' BackupDumperTestP2Summary3 wikitext @@ -586,7 +633,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { ' . ( $this->revId2_3 + $i * self::$numOfRevs ) . ' 2012-04-01T16:46:05Z - 127.0.0.1 + ' . $username . ' + ' . $userid . ' BackupDumperTestP2Summary4 extra wikitext @@ -606,7 +654,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { ' . ( $this->revId4_1 + $i * self::$numOfRevs ) . ' 2012-04-01T16:46:05Z - 127.0.0.1 + ' . $username . ' + ' . $userid . ' Talk BackupDumperTestP1 Summary1 BackupTextPassTestModel