<?php
-require_once __DIR__ . "/../../../maintenance/backupTextPass.inc";
+require_once __DIR__ . "/../../../maintenance/dumpTextPass.php";
/**
* Tests for TextPassDumper that rely on the database
*
+ * Some of these tests use the old constuctor for TextPassDumper
+ * and the dump() function, while others use the new loadWithArgv( $args )
+ * function and execute(). This is to ensure both the old and new methods
+ * work properly.
+ *
* @group Database
* @group Dump
* @covers TextPassDumper
$this->tablesUsed[] = 'revision';
$this->tablesUsed[] = 'text';
- $this->mergeMwGlobalArrayValue( 'wgContentHandlers', array(
+ $this->mergeMwGlobalArrayValue( 'wgContentHandlers', [
"BackupTextPassTestModel" => "BackupTextPassTestModelHandler"
- ) );
+ ] );
$ns = $this->getDefaultWikitextNS();
// 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" );
}
// Setting up the dump
$nameStub = $this->setUpStub();
$nameFull = $this->getNewTempFile();
- $dumper = new TextPassDumper( array( "--stub=file:" . $nameStub,
- "--output=file:" . $nameFull ) );
+ $dumper = new TextPassDumper( [ "--stub=file:" . $nameStub,
+ "--output=file:" . $nameFull ] );
$dumper->reporting = false;
- $dumper->setDb( $this->db );
+ $dumper->setDB( $this->db );
// Performing the dump
$dumper->dump( WikiExporter::FULL, WikiExporter::TEXT );
function testPrefetchPlain() {
// The mapping between ids and text, for the hits of the prefetch mock
- $prefetchMap = array(
- array( $this->pageId1, $this->revId1_1, "Prefetch_________1Text1" ),
- array( $this->pageId2, $this->revId2_3, "Prefetch_________2Text3" )
- );
+ $prefetchMap = [
+ [ $this->pageId1, $this->revId1_1, "Prefetch_________1Text1" ],
+ [ $this->pageId2, $this->revId2_3, "Prefetch_________2Text3" ]
+ ];
// The mock itself
- $prefetchMock = $this->getMock( 'BaseDump', array( 'prefetch' ), array(), '', false );
+ $prefetchMock = $this->getMock( 'BaseDump', [ 'prefetch' ], [], '', false );
$prefetchMock->expects( $this->exactly( 6 ) )
->method( 'prefetch' )
->will( $this->returnValueMap( $prefetchMap ) );
// Setting up of the dump
$nameStub = $this->setUpStub();
$nameFull = $this->getNewTempFile();
- $dumper = new TextPassDumper( array( "--stub=file:"
- . $nameStub, "--output=file:" . $nameFull ) );
+
+ $dumper = new TextPassDumper( [ "--stub=file:" . $nameStub,
+ "--output=file:" . $nameFull ] );
+
$dumper->prefetch = $prefetchMock;
$dumper->reporting = false;
- $dumper->setDb( $this->db );
+ $dumper->setDB( $this->db );
// Performing the dump
$dumper->dump( WikiExporter::FULL, WikiExporter::TEXT );
$this->assertTrue( wfMkdirParents( $nameOutputDir ),
"Creating temporary output directory " );
$this->setUpStub( $nameStub, $iterations );
- $dumper = new TextPassDumper( array( "--stub=file:" . $nameStub,
+ $dumper = new TextPassDumper();
+ $dumper->loadWithArgv( [ "--stub=file:" . $nameStub,
"--output=" . $checkpointFormat . ":" . $nameOutputDir . "/full",
"--maxtime=1" /*This is in minutes. Fixup is below*/,
"--buffersize=32768", // The default of 32 iterations fill up 32KB about twice
- "--checkpointfile=checkpoint-%s-%s.xml.gz" ) );
- $dumper->setDb( $this->db );
+ "--checkpointfile=checkpoint-%s-%s.xml.gz" ] );
+ $dumper->setDB( $this->db );
$dumper->maxTimeAllowed = $checkpointAfter; // Patching maxTime from 1 minute
$dumper->stderr = $stderr;
// The actual dump and taking time
$ts_before = microtime( true );
- $dumper->dump( WikiExporter::FULL, WikiExporter::TEXT );
+ $dumper->execute();
$ts_after = microtime( true );
$lastDuration = $ts_after - $ts_before;
// The dump (hopefully) did take long enough to produce more than one
// checkpoint file.
- //
// We now check all the checkpoint files for validity.
$files = scandir( $nameOutputDir );
. 'xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.10/ '
. 'http://www.mediawiki.org/xml/export-0.10.xsd" version="0.10" xml:lang="en">
<siteinfo>
- <sitename>wikisvn</sitename>
- <base>http://localhost/wiki-svn/index.php/Main_Page</base>
- <generator>MediaWiki 1.21alpha</generator>
- <case>first-letter</case>
- <namespaces>
- <namespace key="-2" case="first-letter">Media</namespace>
- <namespace key="-1" case="first-letter">Special</namespace>
- <namespace key="0" case="first-letter" />
- <namespace key="1" case="first-letter">Talk</namespace>
- <namespace key="2" case="first-letter">User</namespace>
- <namespace key="3" case="first-letter">User talk</namespace>
- <namespace key="4" case="first-letter">Wikisvn</namespace>
- <namespace key="5" case="first-letter">Wikisvn talk</namespace>
- <namespace key="6" case="first-letter">File</namespace>
- <namespace key="7" case="first-letter">File talk</namespace>
- <namespace key="8" case="first-letter">MediaWiki</namespace>
- <namespace key="9" case="first-letter">MediaWiki talk</namespace>
- <namespace key="10" case="first-letter">Template</namespace>
- <namespace key="11" case="first-letter">Template talk</namespace>
- <namespace key="12" case="first-letter">Help</namespace>
- <namespace key="13" case="first-letter">Help talk</namespace>
- <namespace key="14" case="first-letter">Category</namespace>
- <namespace key="15" case="first-letter">Category talk</namespace>
- </namespaces>
+ <sitename>wikisvn</sitename>
+ <base>http://localhost/wiki-svn/index.php/Main_Page</base>
+ <generator>MediaWiki 1.21alpha</generator>
+ <case>first-letter</case>
+ <namespaces>
+ <namespace key="-2" case="first-letter">Media</namespace>
+ <namespace key="-1" case="first-letter">Special</namespace>
+ <namespace key="0" case="first-letter" />
+ <namespace key="1" case="first-letter">Talk</namespace>
+ <namespace key="2" case="first-letter">User</namespace>
+ <namespace key="3" case="first-letter">User talk</namespace>
+ <namespace key="4" case="first-letter">Wikisvn</namespace>
+ <namespace key="5" case="first-letter">Wikisvn talk</namespace>
+ <namespace key="6" case="first-letter">File</namespace>
+ <namespace key="7" case="first-letter">File talk</namespace>
+ <namespace key="8" case="first-letter">MediaWiki</namespace>
+ <namespace key="9" case="first-letter">MediaWiki talk</namespace>
+ <namespace key="10" case="first-letter">Template</namespace>
+ <namespace key="11" case="first-letter">Template talk</namespace>
+ <namespace key="12" case="first-letter">Help</namespace>
+ <namespace key="13" case="first-letter">Help talk</namespace>
+ <namespace key="14" case="first-letter">Category</namespace>
+ <namespace key="15" case="first-letter">Category talk</namespace>
+ </namespaces>
</siteinfo>
';
$tail = '</mediawiki>
for ( $i = 0; $i < $iterations; $i++ ) {
$page1 = ' <page>
- <title>BackupDumperTestP1</title>
- <ns>0</ns>
- <id>' . ( $this->pageId1 + $i * self::$numOfPages ) . '</id>
- <revision>
- <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>
- <model>wikitext</model>
- <format>text/x-wiki</format>
- <text id="' . $this->textId1_1 . '" bytes="23" />
- <sha1>0bolhl6ol7i6x0e7yq91gxgaan39j87</sha1>
- </revision>
+ <title>BackupDumperTestP1</title>
+ <ns>0</ns>
+ <id>' . ( $this->pageId1 + $i * self::$numOfPages ) . '</id>
+ <revision>
+ <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>
+ <model>wikitext</model>
+ <format>text/x-wiki</format>
+ <text id="' . $this->textId1_1 . '" bytes="23" />
+ <sha1>0bolhl6ol7i6x0e7yq91gxgaan39j87</sha1>
+ </revision>
</page>
';
$page2 = ' <page>
- <title>BackupDumperTestP2</title>
- <ns>0</ns>
- <id>' . ( $this->pageId2 + $i * self::$numOfPages ) . '</id>
- <revision>
- <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>
- <model>wikitext</model>
- <format>text/x-wiki</format>
- <text id="' . $this->textId2_1 . '" bytes="23" />
- <sha1>jprywrymfhysqllua29tj3sc7z39dl2</sha1>
- </revision>
- <revision>
- <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>
- <model>wikitext</model>
- <format>text/x-wiki</format>
- <text id="' . $this->textId2_2 . '" bytes="23" />
- <sha1>b7vj5ks32po5m1z1t1br4o7scdwwy95</sha1>
- </revision>
- <revision>
- <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>
- <model>wikitext</model>
- <format>text/x-wiki</format>
- <text id="' . $this->textId2_3 . '" bytes="23" />
- <sha1>jfunqmh1ssfb8rs43r19w98k28gg56r</sha1>
- </revision>
- <revision>
- <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>
- <model>wikitext</model>
- <format>text/x-wiki</format>
- <text id="' . $this->textId2_4 . '" bytes="44" />
- <sha1>6o1ciaxa6pybnqprmungwofc4lv00wv</sha1>
- </revision>
+ <title>BackupDumperTestP2</title>
+ <ns>0</ns>
+ <id>' . ( $this->pageId2 + $i * self::$numOfPages ) . '</id>
+ <revision>
+ <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>
+ <model>wikitext</model>
+ <format>text/x-wiki</format>
+ <text id="' . $this->textId2_1 . '" bytes="23" />
+ <sha1>jprywrymfhysqllua29tj3sc7z39dl2</sha1>
+ </revision>
+ <revision>
+ <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>
+ <model>wikitext</model>
+ <format>text/x-wiki</format>
+ <text id="' . $this->textId2_2 . '" bytes="23" />
+ <sha1>b7vj5ks32po5m1z1t1br4o7scdwwy95</sha1>
+ </revision>
+ <revision>
+ <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>
+ <model>wikitext</model>
+ <format>text/x-wiki</format>
+ <text id="' . $this->textId2_3 . '" bytes="23" />
+ <sha1>jfunqmh1ssfb8rs43r19w98k28gg56r</sha1>
+ </revision>
+ <revision>
+ <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>
+ <model>wikitext</model>
+ <format>text/x-wiki</format>
+ <text id="' . $this->textId2_4 . '" bytes="44" />
+ <sha1>6o1ciaxa6pybnqprmungwofc4lv00wv</sha1>
+ </revision>
</page>
';
// page 3 not in stub
$page4 = ' <page>
- <title>Talk:BackupDumperTestP1</title>
- <ns>1</ns>
- <id>' . ( $this->pageId4 + $i * self::$numOfPages ) . '</id>
- <revision>
- <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>
- <model>BackupTextPassTestModel</model>
- <format>text/plain</format>
- <text id="' . $this->textId4_1 . '" bytes="35" />
- <sha1>nktofwzd0tl192k3zfepmlzxoax1lpe</sha1>
- </revision>
+ <title>Talk:BackupDumperTestP1</title>
+ <ns>1</ns>
+ <id>' . ( $this->pageId4 + $i * self::$numOfPages ) . '</id>
+ <revision>
+ <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>
+ <model>BackupTextPassTestModel</model>
+ <format>text/plain</format>
+ <text id="' . $this->textId4_1 . '" bytes="35" />
+ <sha1>nktofwzd0tl192k3zfepmlzxoax1lpe</sha1>
+ </revision>
</page>
';
$content .= $page1 . $page2 . $page4;
* @dataProvider bufferSizeProvider
*/
function testBufferSizeSetting( $expected, $size, $msg ) {
- $dumper = new TextPassDumperAccessor( array( "--buffersize=" . $size ) );
+ $dumper = new TextPassDumperAccessor();
+ $dumper->loadWithArgv( [ "--buffersize=" . $size ] );
+ $dumper->execute();
$this->assertEquals( $expected, $dumper->getBufferSize(), $msg );
}
*/
function bufferSizeProvider() {
// expected, bufferSize to initialize with, message
- return array(
- array( 512 * 1024, 512 * 1024, "Setting 512KB is not effective" ),
- array( 8192, 8192, "Setting 8KB is not effective" ),
- array( 4096, 2048, "Could set buffer size below lower bound" )
- );
+ return [
+ [ 512 * 1024, 512 * 1024, "Setting 512KB is not effective" ],
+ [ 8192, 8192, "Setting 8KB is not effective" ],
+ [ 4096, 2048, "Could set buffer size below lower bound" ]
+ ];
}
}
public function getBufferSize() {
return $this->bufferSize;
}
+
+ function dump( $history, $text = null ) {
+ return true;
+ }
}