26 protected $xml =
null;
39 if ( $status->isGood() ) {
40 $value = $status->getValue();
41 $revision =
$value[
'revision'];
42 $revision_id = $revision->getId();
43 $text_id = $revision->getTextId();
44 if ( ( $revision_id > 0 ) && ( $text_id > 0 ) ) {
45 return array( $revision_id, $text_id );
48 throw new MWException(
"Could not determine revision id (" . $status->getWikiText() .
")" );
58 $gzipped_contents = file_get_contents(
$fname );
59 if ( $gzipped_contents ===
false ) {
60 $this->
fail(
"Could not get contents of $fname" );
63 $contents = gzdecode( $gzipped_contents );
67 file_put_contents(
$fname, $contents ),
77 protected function setUp() {
82 if ( $this->exceptionFromAddDBData !==
null ) {
100 $this->expectOutputRegex(
'//' );
103 $lines = explode(
"\n", $this->getActualOutput() );
104 $this->assertGreaterThan( 1, count(
$lines ),
"Minimal lines of produced output" );
105 $this->assertEquals(
'', array_pop(
$lines ),
"Output ends in LF" );
106 $timestamp_re =
"[0-9]{4}-[01][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-6][0-9]";
108 $this->assertRegExp(
"/$timestamp_re: .* \(ID [0-9]+\) [0-9]* pages .*, [0-9]* revs .*, ETA/",
$line );
121 while ( $this->xml->read() ) {
122 if ( $this->xml->nodeType == XMLReader::END_ELEMENT &&
123 $this->xml->name ==
$name
144 "Skipping to end of $name" );
145 while ( $this->xml->read() ) {
146 if ( $this->xml->nodeType == XMLReader::ELEMENT ) {
162 $this->xml =
new XMLReader();
163 $this->assertTrue( $this->xml->open(
$fname ),
164 "Opening temporary file $fname via XMLReader failed" );
165 if ( $skip_siteinfo ) {
167 "Skipping past end of siteinfo" );
180 if ( $this->xml->read() ) {
183 $this->assertEquals( $this->xml->nodeType, XMLReader::NONE,
184 "No proper entity left to parse" );
194 || ( $this->xml->nodeType == XMLReader::SIGNIFICANT_WHITESPACE ) ) ) {
195 $cont = $this->xml->read();
208 $this->assertEquals(
$name, $this->xml->name,
"Node name" );
209 $this->assertEquals( XMLReader::ELEMENT, $this->xml->nodeType,
"Node type" );
211 $this->assertTrue( $this->xml->read(),
"Skipping past start tag" );
224 $this->assertEquals(
$name, $this->xml->name,
"Node name" );
225 $this->assertEquals( XMLReader::END_ELEMENT, $this->xml->nodeType,
"Node type" );
227 $this->assertTrue( $this->xml->read(),
"Skipping past end tag" );
245 if ( $text !==
false ) {
246 $this->assertEquals( $text, $this->xml->value,
"Text of node " .
$name );
248 $this->assertTrue( $this->xml->read(),
"Skipping past processed text of " .
$name );
302 protected function assertRevision( $id,
$summary, $text_id, $text_bytes, $text_sha1, $text =
false, $parentid =
false,
309 if ( $parentid !==
false ) {
323 if ( $this->xml->name ==
"text" ) {
326 $this->
assertText( $id, $text_id, $text_bytes, $text );
339 if ( !$text_found ) {
340 $this->
assertText( $id, $text_id, $text_bytes, $text );
347 protected function assertText( $id, $text_id, $text_bytes, $text ) {
349 if ( $text_bytes !==
false ) {
350 $this->assertEquals( $this->xml->getAttribute(
"bytes" ), $text_bytes,
351 "Attribute 'bytes' of revision " . $id );
354 if ( $text ===
false ) {
356 $this->assertEquals( $this->xml->getAttribute(
"id" ), $text_id,
357 "Text id of revision " . $id );
358 $this->assertFalse( $this->xml->hasValue,
"Revision has text" );
359 $this->assertTrue( $this->xml->read(),
"Skipping text start tag" );
360 if ( ( $this->xml->nodeType == XMLReader::END_ELEMENT )
361 && ( $this->xml->name ==
"text" )
369 $this->assertTrue( $this->xml->read(),
"Skipping text start tag" );
370 $this->assertEquals( $text, $this->xml->value,
"Text of revision " . $id );
371 $this->assertTrue( $this->xml->read(),
"Skipping past text" );