merged master
[lhc/web/wiklou.git] / tests / phpunit / maintenance / backupTextPassTest.php
index 6cdba85..31bb8b7 100644 (file)
@@ -12,12 +12,14 @@ class TextPassDumperTest extends DumpTestCase {
 
        // We'll add several pages, revision and texts. The following variables hold the
        // corresponding ids.
-       private $pageId1, $pageId2, $pageId3, $pageId4, $pageId5;
+       private $pageId1, $pageId2, $pageId3, $pageId4;
+       private static $numOfPages = 4;
        private $revId1_1, $textId1_1;
        private $revId2_1, $textId2_1, $revId2_2, $textId2_2;
        private $revId2_3, $textId2_3, $revId2_4, $textId2_4;
        private $revId3_1, $textId3_1, $revId3_2, $textId3_2;
        private $revId4_1, $textId4_1;
+       private static $numOfRevs = 8;
 
        function addDBData() {
                $this->tablesUsed[] = 'page';
@@ -112,16 +114,16 @@ class TextPassDumperTest extends DumpTestCase {
                $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" );
                $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1",
                        $this->textId2_1, false, "jprywrymfhysqllua29tj3sc7z39dl2",
-                       "BackupDumperTestP2Text1", $this->revId2_2 );
+                       "BackupDumperTestP2Text1" );
                $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2",
                        $this->textId2_2, false, "b7vj5ks32po5m1z1t1br4o7scdwwy95",
-                       "BackupDumperTestP2Text2", $this->revId2_3 );
+                       "BackupDumperTestP2Text2", $this->revId2_1 );
                $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3",
                        $this->textId2_3, false, "jfunqmh1ssfb8rs43r19w98k28gg56r",
-                       "BackupDumperTestP2Text3", $this->revId2_4 );
+                       "BackupDumperTestP2Text3", $this->revId2_2 );
                $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra",
                        $this->textId2_4, false, "6o1ciaxa6pybnqprmungwofc4lv00wv",
-                       "BackupDumperTestP2Text4 some additional Text" );
+                       "BackupDumperTestP2Text4 some additional Text", $this->revId2_3 );
                $this->assertPageEnd();
 
                // Page 3
@@ -178,18 +180,18 @@ class TextPassDumperTest extends DumpTestCase {
                $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" );
                $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1",
                        $this->textId2_1, false, "jprywrymfhysqllua29tj3sc7z39dl2",
-                       "BackupDumperTestP2Text1", $this->revId2_2 );
+                       "BackupDumperTestP2Text1" );
                $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2",
                        $this->textId2_2, false, "b7vj5ks32po5m1z1t1br4o7scdwwy95",
-                       "BackupDumperTestP2Text2", $this->revId2_3 );
+                       "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",
                        $this->textId2_3, false, "jfunqmh1ssfb8rs43r19w98k28gg56r",
-                       "Prefetch_________2Text3", $this->revId2_4 );
+                       "Prefetch_________2Text3", $this->revId2_2 );
                $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra",
                        $this->textId2_4, false, "6o1ciaxa6pybnqprmungwofc4lv00wv",
-                       "BackupDumperTestP2Text4 some additional Text" );
+                       "BackupDumperTestP2Text4 some additional Text", $this->revId2_3 );
                $this->assertPageEnd();
 
                // Page 3
@@ -314,9 +316,9 @@ class TextPassDumperTest extends DumpTestCase {
                        switch ( $lookingForPage ) {
                        case 1:
                                // Page 1
-                               $this->assertPageStart( $this->pageId1 + $i * 4, NS_MAIN,
+                               $this->assertPageStart( $this->pageId1 + $i * self::$numOfPages, NS_MAIN,
                                        "BackupDumperTestP1" );
-                               $this->assertRevision( $this->revId1_1, "BackupDumperTestP1Summary1",
+                               $this->assertRevision( $this->revId1_1 + $i * self::$numOfRevs, "BackupDumperTestP1Summary1",
                                        $this->textId1_1, false, "0bolhl6ol7i6x0e7yq91gxgaan39j87",
                                        "BackupDumperTestP1Text1" );
                                $this->assertPageEnd();
@@ -326,21 +328,22 @@ class TextPassDumperTest extends DumpTestCase {
 
                        case 2:
                                // Page 2
-                               $this->assertPageStart( $this->pageId2 + $i * 4, NS_MAIN,
+                               $this->assertPageStart( $this->pageId2 + $i * self::$numOfPages, NS_MAIN,
                                        "BackupDumperTestP2" );
-                               $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1",
+                               $this->assertRevision( $this->revId2_1 + $i * self::$numOfRevs, "BackupDumperTestP2Summary1",
                                        $this->textId2_1, false, "jprywrymfhysqllua29tj3sc7z39dl2",
-                                       "BackupDumperTestP2Text1", $this->revId2_2 );
-                               $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2",
+                                       "BackupDumperTestP2Text1" );
+                               $this->assertRevision( $this->revId2_2 + $i * self::$numOfRevs, "BackupDumperTestP2Summary2",
                                        $this->textId2_2, false, "b7vj5ks32po5m1z1t1br4o7scdwwy95",
-                                       "BackupDumperTestP2Text2", $this->revId2_3 );
-                               $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3",
+                                       "BackupDumperTestP2Text2", $this->revId2_1 + $i * self::$numOfRevs );
+                               $this->assertRevision( $this->revId2_3 + $i * self::$numOfRevs, "BackupDumperTestP2Summary3",
                                        $this->textId2_3, false, "jfunqmh1ssfb8rs43r19w98k28gg56r",
-                                       "BackupDumperTestP2Text3", $this->revId2_4 );
-                               $this->assertRevision( $this->revId2_4,
+                                       "BackupDumperTestP2Text3", $this->revId2_2 + $i * self::$numOfRevs );
+                               $this->assertRevision( $this->revId2_4 + $i * self::$numOfRevs,
                                        "BackupDumperTestP2Summary4 extra",
                                        $this->textId2_4, false, "6o1ciaxa6pybnqprmungwofc4lv00wv",
-                                       "BackupDumperTestP2Text4 some additional Text" );
+                                       "BackupDumperTestP2Text4 some additional Text",
+                                       $this->revId2_3 + $i * self::$numOfRevs );
                                $this->assertPageEnd();
 
                                $lookingForPage = 4;
@@ -348,9 +351,9 @@ class TextPassDumperTest extends DumpTestCase {
 
                        case 4:
                                // Page 4
-                               $this->assertPageStart( $this->pageId4 + $i * 4, NS_TALK,
+                               $this->assertPageStart( $this->pageId4 + $i * self::$numOfPages, NS_TALK,
                                        "Talk:BackupDumperTestP1" );
-                               $this->assertRevision( $this->revId4_1,
+                               $this->assertRevision( $this->revId4_1 + $i * self::$numOfRevs,
                                        "Talk BackupDumperTestP1 Summary1",
                                        $this->textId4_1, false, "nktofwzd0tl192k3zfepmlzxoax1lpe",
                                        "Talk about BackupDumperTestP1 Text1" );
@@ -380,7 +383,7 @@ class TextPassDumperTest extends DumpTestCase {
                $this->assertEmpty( $files, "Remaining unchecked files" );
 
                // ... and have dealt with more than one checkpoint file
-               $this->assertGreaterThan( 1, $checkpointFiles, "# of checkpoint files" );
+               $this->assertGreaterThan( 1, $checkpointFiles, "expected more than 1 checkpoint to have been created. Checkpoint interval is $checkpointAfter seconds, maybe your computer is too fast?" );
 
                $this->expectETAOutput();
        }
@@ -417,10 +420,10 @@ class TextPassDumperTest extends DumpTestCase {
         *           file is generated that is automatically removed upon
         *           tearDown.
         * @param $iterations integer: (Optional) specifies how often the block
-        *           of 3 pages should go into the stub file. The page id
-        *           increase further and further, while the revision and text
-        *           ids of the first iteration are reused. The pages of
-        *           iteration > 1 have no corresponding representation in the
+        *           of 3 pages should go into the stub file. The page and
+        *           revision id increase further and further, while the text
+        *           id of the first iteration is reused. The pages and revision
+        *           of iteration > 1 have no corresponding representation in the
         *           database.
         * @return string absolute filename of the stub
         */
@@ -469,15 +472,17 @@ class TextPassDumperTest extends DumpTestCase {
                        $page1 = '  <page>
     <title>BackupDumperTestP1</title>
     <ns>0</ns>
-    <id>' . ( $this->pageId1 + $i * 4 ) . '</id>
+    <id>' . ( $this->pageId1 + $i * self::$numOfPages ) . '</id>
     <revision>
-      <id>' . $this->revId1_1 . '</id>
+      <id>' . ( $this->revId1_1 + $i * self::$numOfRevs ) . '</id>
       <timestamp>2012-04-01T16:46:05Z</timestamp>
       <contributor>
         <ip>127.0.0.1</ip>
       </contributor>
       <comment>BackupDumperTestP1Summary1</comment>
       <sha1>0bolhl6ol7i6x0e7yq91gxgaan39j87</sha1>
+      <model>wikitext</model>
+      <format>text/x-wiki</format>
       <text id="' . $this->textId1_1 . '" bytes="23" />
     </revision>
   </page>
@@ -485,48 +490,56 @@ class TextPassDumperTest extends DumpTestCase {
                        $page2 = '  <page>
     <title>BackupDumperTestP2</title>
     <ns>0</ns>
-    <id>' . ( $this->pageId2 + $i * 4 ) . '</id>
+    <id>' . ( $this->pageId2 + $i * self::$numOfPages ) . '</id>
     <revision>
-      <id>' . $this->revId2_1 . '</id>
-      <parentid>' . $this->revId2_2 . '</parentid>
+      <id>' . ( $this->revId2_1 + $i * self::$numOfRevs ) . '</id>
       <timestamp>2012-04-01T16:46:05Z</timestamp>
       <contributor>
         <ip>127.0.0.1</ip>
       </contributor>
       <comment>BackupDumperTestP2Summary1</comment>
       <sha1>jprywrymfhysqllua29tj3sc7z39dl2</sha1>
+      <model>wikitext</model>
+      <format>text/x-wiki</format>
       <text id="' . $this->textId2_1 . '" bytes="23" />
     </revision>
     <revision>
-      <id>' . $this->revId2_2 . '</id>
-      <parentid>' . $this->revId2_3 . '</parentid>
+      <id>' . ( $this->revId2_2 + $i * self::$numOfRevs ) . '</id>
+      <parentid>' . ( $this->revId2_1 + $i * self::$numOfRevs ) . '</parentid>
       <timestamp>2012-04-01T16:46:05Z</timestamp>
       <contributor>
         <ip>127.0.0.1</ip>
       </contributor>
       <comment>BackupDumperTestP2Summary2</comment>
       <sha1>b7vj5ks32po5m1z1t1br4o7scdwwy95</sha1>
+      <model>wikitext</model>
+      <format>text/x-wiki</format>
       <text id="' . $this->textId2_2 . '" bytes="23" />
     </revision>
     <revision>
-      <id>' . $this->revId2_3 . '</id>
-      <parentid>' . $this->revId2_4 . '</parentid>
+      <id>' . ( $this->revId2_3 + $i * self::$numOfRevs ) . '</id>
+      <parentid>' . ( $this->revId2_2 + $i * self::$numOfRevs ) . '</parentid>
       <timestamp>2012-04-01T16:46:05Z</timestamp>
       <contributor>
         <ip>127.0.0.1</ip>
       </contributor>
       <comment>BackupDumperTestP2Summary3</comment>
       <sha1>jfunqmh1ssfb8rs43r19w98k28gg56r</sha1>
+      <model>wikitext</model>
+      <format>text/x-wiki</format>
       <text id="' . $this->textId2_3 . '" bytes="23" />
     </revision>
     <revision>
-      <id>' . $this->revId2_4 . '</id>
+      <id>' . ( $this->revId2_4 + $i * self::$numOfRevs ) . '</id>
+      <parentid>' . ( $this->revId2_3 + $i * self::$numOfRevs ) . '</parentid>
       <timestamp>2012-04-01T16:46:05Z</timestamp>
       <contributor>
         <ip>127.0.0.1</ip>
       </contributor>
       <comment>BackupDumperTestP2Summary4 extra</comment>
       <sha1>6o1ciaxa6pybnqprmungwofc4lv00wv</sha1>
+      <model>wikitext</model>
+      <format>text/x-wiki</format>
       <text id="' . $this->textId2_4 . '" bytes="44" />
     </revision>
   </page>
@@ -536,15 +549,17 @@ class TextPassDumperTest extends DumpTestCase {
                        $page4 = '  <page>
     <title>Talk:BackupDumperTestP1</title>
     <ns>1</ns>
-    <id>' . ( $this->pageId4 + $i * 4 ) . '</id>
+    <id>' . ( $this->pageId4 + $i * self::$numOfPages ) . '</id>
     <revision>
-      <id>' . $this->revId4_1 . '</id>
+      <id>' . ( $this->revId4_1 + $i * self::$numOfRevs ) . '</id>
       <timestamp>2012-04-01T16:46:05Z</timestamp>
       <contributor>
         <ip>127.0.0.1</ip>
       </contributor>
       <comment>Talk BackupDumperTestP1 Summary1</comment>
       <sha1>nktofwzd0tl192k3zfepmlzxoax1lpe</sha1>
+      <model>wikitext</model>
+      <format>text/x-wiki</format>
       <text id="' . $this->textId4_1 . '" bytes="35" />
     </revision>
   </page>