Merge "Type hint against LinkTarget in WatchedItemStore"
[lhc/web/wiklou.git] / tests / phpunit / maintenance / backup_PageTest.php
1 <?php
2
3 namespace MediaWiki\Tests\Maintenance;
4
5 use DumpBackup;
6 use Exception;
7 use MediaWiki\MediaWikiServices;
8 use MediaWiki\Revision\RevisionRecord;
9 use MediaWiki\Revision\SlotRecord;
10 use MediaWikiTestCase;
11 use MWException;
12 use RequestContext;
13 use RevisionDeleter;
14 use Title;
15 use WikiExporter;
16 use Wikimedia\Rdbms\IDatabase;
17 use Wikimedia\Rdbms\LoadBalancer;
18 use WikiPage;
19 use XmlDumpWriter;
20
21 /**
22 * Tests for page dumps of BackupDumper
23 *
24 * @group Database
25 * @group Dump
26 * @covers BackupDumper
27 */
28 class BackupDumperPageTest extends DumpTestCase {
29
30 // We'll add several pages, revision and texts. The following variables hold the
31 // corresponding ids.
32 private $pageId1, $pageId2, $pageId3, $pageId4, $pageId5;
33 private $pageTitle1, $pageTitle2, $pageTitle3, $pageTitle4, $pageTitle5;
34 private $revId1_1, $textId1_1;
35 private $revId2_1, $textId2_1, $revId2_2, $textId2_2;
36 private $revId2_3, $textId2_3, $revId2_4, $textId2_4;
37 private $revId3_1, $textId3_1, $revId3_2, $textId3_2;
38 private $revId4_1, $textId4_1;
39 private $revId5_1, $textId5_1;
40 private $namespace, $talk_namespace;
41
42 /**
43 * @var LoadBalancer|null
44 */
45 private $streamingLoadBalancer = null;
46
47 function addDBData() {
48 // be sure, titles created here using english namespace names
49 $this->setContentLang( 'en' );
50
51 $this->tablesUsed[] = 'page';
52 $this->tablesUsed[] = 'revision';
53 $this->tablesUsed[] = 'ip_changes';
54 $this->tablesUsed[] = 'text';
55
56 try {
57 $this->namespace = $this->getDefaultWikitextNS();
58 $this->talk_namespace = NS_TALK;
59
60 if ( $this->namespace === $this->talk_namespace ) {
61 // @todo work around this.
62 throw new MWException( "The default wikitext namespace is the talk namespace. "
63 . " We can't currently deal with that." );
64 }
65
66 $this->pageTitle1 = Title::newFromText( 'BackupDumperTestP1', $this->namespace );
67 $page = WikiPage::factory( $this->pageTitle1 );
68 list( $this->revId1_1, $this->textId1_1 ) = $this->addRevision( $page,
69 "BackupDumperTestP1Text1", "BackupDumperTestP1Summary1" );
70 $this->pageId1 = $page->getId();
71
72 $this->pageTitle2 = Title::newFromText( 'BackupDumperTestP2', $this->namespace );
73 $page = WikiPage::factory( $this->pageTitle2 );
74 list( $this->revId2_1, $this->textId2_1 ) = $this->addRevision( $page,
75 "BackupDumperTestP2Text1", "BackupDumperTestP2Summary1" );
76 list( $this->revId2_2, $this->textId2_2 ) = $this->addRevision( $page,
77 "BackupDumperTestP2Text2", "BackupDumperTestP2Summary2" );
78 list( $this->revId2_3, $this->textId2_3 ) = $this->addRevision( $page,
79 "BackupDumperTestP2Text3", "BackupDumperTestP2Summary3" );
80 list( $this->revId2_4, $this->textId2_4 ) = $this->addRevision( $page,
81 "BackupDumperTestP2Text4 some additional Text ",
82 "BackupDumperTestP2Summary4 extra " );
83 $this->pageId2 = $page->getId();
84
85 $revDel = RevisionDeleter::createList(
86 'revision',
87 RequestContext::getMain(),
88 $this->pageTitle2,
89 [ $this->revId2_2 ]
90 );
91 $revDel->setVisibility( [
92 'value' => [ RevisionRecord::DELETED_TEXT => 1 ],
93 'comment' => 'testing!'
94 ] );
95
96 $this->pageTitle3 = Title::newFromText( 'BackupDumperTestP3', $this->namespace );
97 $page = WikiPage::factory( $this->pageTitle3 );
98 list( $this->revId3_1, $this->textId3_1 ) = $this->addRevision( $page,
99 "BackupDumperTestP3Text1", "BackupDumperTestP2Summary1" );
100 list( $this->revId3_2, $this->textId3_2 ) = $this->addRevision( $page,
101 "BackupDumperTestP3Text2", "BackupDumperTestP2Summary2" );
102 $this->pageId3 = $page->getId();
103 $page->doDeleteArticle( "Testing ;)" );
104
105 $this->pageTitle4 = Title::newFromText( 'BackupDumperTestP1', $this->talk_namespace );
106 $page = WikiPage::factory( $this->pageTitle4 );
107 list( $this->revId4_1, $this->textId4_1 ) = $this->addRevision( $page,
108 "Talk about BackupDumperTestP1 Text1",
109 "Talk BackupDumperTestP1 Summary1" );
110 $this->pageId4 = $page->getId();
111
112 $this->pageTitle5 = Title::newFromText( 'BackupDumperTestP5' );
113 $page = WikiPage::factory( $this->pageTitle5 );
114 list( $this->revId5_1, $this->textId5_1 ) = $this->addRevision( $page,
115 "BackupDumperTestP5 Text1",
116 "BackupDumperTestP5 Summary1" );
117 $this->pageId5 = $page->getId();
118
119 $this->corruptRevisionData( $page->getRevision()->getRevisionRecord() );
120 } catch ( Exception $e ) {
121 // We'd love to pass $e directly. However, ... see
122 // documentation of exceptionFromAddDBData in
123 // DumpTestCase
124 $this->exceptionFromAddDBData = $e;
125 }
126 }
127
128 /**
129 * Corrupt the information about the given revision in the database.
130 *
131 * @param RevisionRecord $revision
132 */
133 private function corruptRevisionData( RevisionRecord $revision ) {
134 global $wgMultiContentRevisionSchemaMigrationStage;
135
136 if ( ( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) ) {
137 $this->db->update(
138 'revision',
139 [
140 'rev_text_id' => 0,
141 'rev_sha1' => '',
142 'rev_len' => '0',
143 ],
144 [ 'rev_id' => $revision->getId() ]
145 );
146 }
147
148 if ( ( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) ) {
149 $this->db->update(
150 'content',
151 [
152 'content_address' => 'tt:0',
153 'content_sha1' => '',
154 'content_size' => '0',
155 ],
156 [ 'content_id' => $revision->getSlot( SlotRecord::MAIN )->getContentId() ]
157 );
158 }
159 }
160
161 protected function setUp() {
162 parent::setUp();
163
164 // Since we will restrict dumping by page ranges (to allow
165 // working tests, even if the db gets prepopulated by a base
166 // class), we have to assert, that the page id are consecutively
167 // increasing
168 $this->assertEquals(
169 [ $this->pageId2, $this->pageId3, $this->pageId4 ],
170 [ $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ],
171 "Page ids increasing without holes" );
172 }
173
174 function tearDown() {
175 parent::tearDown();
176
177 if ( isset( $this->streamingLoadBalancer ) ) {
178 $this->streamingLoadBalancer->closeAll();
179 }
180 }
181
182 /**
183 * Returns a new database connection which is separate from the conenctions returned
184 * by the default LoadBalancer instance.
185 *
186 * @return IDatabase
187 */
188 private function newStreamingDBConnection() {
189 // Create a *new* LoadBalancer, so no connections are shared
190 if ( !$this->streamingLoadBalancer ) {
191 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
192
193 $this->streamingLoadBalancer = $lbFactory->newMainLB();
194 }
195
196 $db = $this->streamingLoadBalancer->getConnection( DB_REPLICA );
197
198 // Make sure the DB connection has the fake table clones and the fake table prefix
199 MediaWikiTestCase::setupDatabaseWithTestPrefix( $db );
200
201 // Make sure the DB connection has all the test data
202 $this->copyTestData( $this->db, $db );
203
204 return $db;
205 }
206
207 /**
208 * @param array $argv
209 * @param int $startId
210 * @param int $endId
211 *
212 * @return DumpBackup
213 */
214 private function newDumpBackup( $argv, $startId, $endId ) {
215 $dumper = new DumpBackup( $argv );
216 $dumper->startId = $startId;
217 $dumper->endId = $endId;
218 $dumper->reporting = false;
219
220 // NOTE: The copyTestData() method used by newStreamingDBConnection()
221 // doesn't work with SQLite (T217607).
222 // But DatabaseSqlite doesn't support streaming anyway, so just skip that part.
223 if ( $this->db->getType() === 'sqlite' ) {
224 $dumper->setDB( $this->db );
225 } else {
226 $dumper->setDB( $this->newStreamingDBConnection() );
227 }
228
229 return $dumper;
230 }
231
232 public function schemaVersionProvider() {
233 foreach ( XmlDumpWriter::$supportedSchemas as $schemaVersion ) {
234 yield [ $schemaVersion ];
235 }
236 }
237
238 /**
239 * @dataProvider schemaVersionProvider
240 */
241 function testFullTextPlain( $schemaVersion ) {
242 // Preparing the dump
243 $fname = $this->getNewTempFile();
244
245 $dumper = $this->newDumpBackup(
246 [ '--full', '--quiet', '--output', 'file:' . $fname, '--schema-version', $schemaVersion ],
247 $this->pageId1,
248 $this->pageId5 + 1
249 );
250
251 // Performing the dump. Suppress warnings, since we want to test
252 // accessing broken revision data (page 5).
253 $this->setMwGlobals( 'wgDevelopmentWarnings', false );
254 $dumper->execute();
255 $this->setMwGlobals( 'wgDevelopmentWarnings', true );
256
257 // Checking the dumped data
258 $this->assertDumpSchema( $fname, $this->getXmlSchemaPath( $schemaVersion ) );
259 $asserter = $this->getDumpAsserter( $schemaVersion );
260
261 $asserter->assertDumpStart( $fname );
262
263 // Page 1
264 $asserter->assertPageStart(
265 $this->pageId1,
266 $this->namespace,
267 $this->pageTitle1->getPrefixedText()
268 );
269 $asserter->assertRevision(
270 $this->revId1_1,
271 "BackupDumperTestP1Summary1",
272 $this->textId1_1,
273 23,
274 "0bolhl6ol7i6x0e7yq91gxgaan39j87",
275 "BackupDumperTestP1Text1"
276 );
277 $asserter->assertPageEnd();
278
279 // Page 2
280 $asserter->assertPageStart(
281 $this->pageId2,
282 $this->namespace,
283 $this->pageTitle2->getPrefixedText()
284 );
285 $asserter->assertRevision(
286 $this->revId2_1,
287 "BackupDumperTestP2Summary1",
288 $this->textId2_1,
289 23,
290 "jprywrymfhysqllua29tj3sc7z39dl2",
291 "BackupDumperTestP2Text1"
292 );
293 $asserter->assertRevision(
294 $this->revId2_2,
295 "BackupDumperTestP2Summary2",
296 null, // deleted!
297 false, // deleted!
298 null, // deleted!
299 false, // deleted!
300 $this->revId2_1
301 );
302 $asserter->assertRevision(
303 $this->revId2_3,
304 "BackupDumperTestP2Summary3",
305 $this->textId2_3,
306 23,
307 "jfunqmh1ssfb8rs43r19w98k28gg56r",
308 "BackupDumperTestP2Text3",
309 $this->revId2_2
310 );
311 $asserter->assertRevision(
312 $this->revId2_4,
313 "BackupDumperTestP2Summary4 extra",
314 $this->textId2_4,
315 44,
316 "6o1ciaxa6pybnqprmungwofc4lv00wv",
317 "BackupDumperTestP2Text4 some additional Text",
318 $this->revId2_3
319 );
320 $asserter->assertPageEnd();
321
322 // Page 3
323 // -> Page is marked deleted. Hence not visible
324
325 // Page 4
326 $asserter->assertPageStart(
327 $this->pageId4,
328 $this->talk_namespace,
329 $this->pageTitle4->getPrefixedText()
330 );
331 $asserter->assertRevision(
332 $this->revId4_1,
333 "Talk BackupDumperTestP1 Summary1",
334 $this->textId4_1,
335 35,
336 "nktofwzd0tl192k3zfepmlzxoax1lpe",
337 "Talk about BackupDumperTestP1 Text1",
338 false,
339 CONTENT_MODEL_WIKITEXT,
340 CONTENT_FORMAT_WIKITEXT,
341 $schemaVersion
342 );
343 $asserter->assertPageEnd();
344
345 // Page 5 (broken revision data)
346 $asserter->assertPageStart(
347 $this->pageId5,
348 $this->namespace,
349 $this->pageTitle5->getPrefixedText()
350 );
351 $asserter->assertRevision(
352 $this->revId5_1,
353 "BackupDumperTestP5 Summary1",
354 null,
355 0,
356 "",
357 false,
358 false,
359 CONTENT_MODEL_WIKITEXT,
360 CONTENT_FORMAT_WIKITEXT,
361 $schemaVersion
362 );
363 $asserter->assertPageEnd();
364
365 $asserter->assertDumpEnd();
366
367 // FIXME: add multi-slot test case!
368 }
369
370 /**
371 * @dataProvider schemaVersionProvider
372 */
373 function testFullStubPlain( $schemaVersion ) {
374 // Preparing the dump
375 $fname = $this->getNewTempFile();
376
377 $dumper = $this->newDumpBackup(
378 [
379 '--full',
380 '--quiet',
381 '--output',
382 'file:' . $fname,
383 '--stub',
384 '--schema-version', $schemaVersion,
385 ],
386 $this->pageId1,
387 $this->pageId5 + 1
388 );
389
390 // Performing the dump. Suppress warnings, since we want to test
391 // accessing broken revision data (page 5).
392 $this->setMwGlobals( 'wgDevelopmentWarnings', false );
393 $dumper->execute();
394 $this->setMwGlobals( 'wgDevelopmentWarnings', true );
395
396 // Checking the dumped data
397 $this->assertDumpSchema( $fname, $this->getXmlSchemaPath( $schemaVersion ) );
398 $asserter = $this->getDumpAsserter( $schemaVersion );
399
400 $asserter->assertDumpStart( $fname );
401
402 // Page 1
403 $asserter->assertPageStart(
404 $this->pageId1,
405 $this->namespace,
406 $this->pageTitle1->getPrefixedText()
407 );
408 $asserter->assertRevision(
409 $this->revId1_1,
410 "BackupDumperTestP1Summary1",
411 $this->textId1_1,
412 23,
413 "0bolhl6ol7i6x0e7yq91gxgaan39j87"
414 );
415 $asserter->assertPageEnd();
416
417 // Page 2
418 $asserter->assertPageStart(
419 $this->pageId2,
420 $this->namespace,
421 $this->pageTitle2->getPrefixedText()
422 );
423 $asserter->assertRevision(
424 $this->revId2_1,
425 "BackupDumperTestP2Summary1",
426 $this->textId2_1,
427 23,
428 "jprywrymfhysqllua29tj3sc7z39dl2"
429 );
430 $asserter->assertRevision(
431 $this->revId2_2,
432 "BackupDumperTestP2Summary2",
433 null, // deleted!
434 false, // deleted!
435 null, // deleted!
436 false, // deleted!
437 $this->revId2_1
438 );
439 $asserter->assertRevision(
440 $this->revId2_3,
441 "BackupDumperTestP2Summary3",
442 $this->textId2_3,
443 23,
444 "jfunqmh1ssfb8rs43r19w98k28gg56r",
445 false,
446 $this->revId2_2
447 );
448 $asserter->assertRevision(
449 $this->revId2_4,
450 "BackupDumperTestP2Summary4 extra",
451 $this->textId2_4,
452 44,
453 "6o1ciaxa6pybnqprmungwofc4lv00wv",
454 false,
455 $this->revId2_3
456 );
457 $asserter->assertPageEnd();
458
459 // Page 3
460 // -> Page is marked deleted. Hence not visible
461
462 // Page 4
463 $asserter->assertPageStart(
464 $this->pageId4,
465 $this->talk_namespace,
466 $this->pageTitle4->getPrefixedText()
467 );
468 $asserter->assertRevision(
469 $this->revId4_1,
470 "Talk BackupDumperTestP1 Summary1",
471 $this->textId4_1,
472 35,
473 "nktofwzd0tl192k3zfepmlzxoax1lpe"
474 );
475 $asserter->assertPageEnd();
476
477 // Page 5 (broken revision data)
478 $asserter->assertPageStart(
479 $this->pageId5,
480 $this->namespace,
481 $this->pageTitle5->getPrefixedText()
482 );
483 $asserter->assertRevision(
484 $this->revId5_1,
485 "BackupDumperTestP5 Summary1",
486 null,
487 0,
488 ""
489 );
490 $asserter->assertPageEnd();
491
492 $asserter->assertDumpEnd();
493 }
494
495 /**
496 * @dataProvider schemaVersionProvider
497 */
498 function testCurrentStubPlain( $schemaVersion ) {
499 // Preparing the dump
500 $fname = $this->getNewTempFile();
501
502 $dumper = $this->newDumpBackup(
503 [ '--output', 'file:' . $fname, '--schema-version', $schemaVersion ],
504 $this->pageId1,
505 $this->pageId4 + 1
506 );
507
508 // Performing the dump
509 $dumper->dump( WikiExporter::CURRENT, WikiExporter::STUB );
510
511 // Checking the dumped data
512 $this->assertDumpSchema( $fname, $this->getXmlSchemaPath( $schemaVersion ) );
513
514 $asserter = $this->getDumpAsserter( $schemaVersion );
515 $asserter->assertDumpStart( $fname );
516
517 // Page 1
518 $asserter->assertPageStart(
519 $this->pageId1,
520 $this->namespace,
521 $this->pageTitle1->getPrefixedText()
522 );
523 $asserter->assertRevision(
524 $this->revId1_1,
525 "BackupDumperTestP1Summary1",
526 $this->textId1_1,
527 23,
528 "0bolhl6ol7i6x0e7yq91gxgaan39j87"
529 );
530 $asserter->assertPageEnd();
531
532 // Page 2
533 $asserter->assertPageStart(
534 $this->pageId2,
535 $this->namespace,
536 $this->pageTitle2->getPrefixedText()
537 );
538 $asserter->assertRevision(
539 $this->revId2_4,
540 "BackupDumperTestP2Summary4 extra",
541 $this->textId2_4,
542 44,
543 "6o1ciaxa6pybnqprmungwofc4lv00wv",
544 false,
545 $this->revId2_3
546 );
547 $asserter->assertPageEnd();
548
549 // Page 3
550 // -> Page is marked deleted. Hence not visible
551
552 // Page 4
553 $asserter->assertPageStart(
554 $this->pageId4,
555 $this->talk_namespace,
556 $this->pageTitle4->getPrefixedText()
557 );
558 $asserter->assertRevision(
559 $this->revId4_1,
560 "Talk BackupDumperTestP1 Summary1",
561 $this->textId4_1,
562 35,
563 "nktofwzd0tl192k3zfepmlzxoax1lpe"
564 );
565 $asserter->assertPageEnd();
566
567 $asserter->assertDumpEnd();
568 }
569
570 function testCurrentStubGzip() {
571 $this->checkHasGzip();
572
573 // Preparing the dump
574 $fname = $this->getNewTempFile();
575
576 $dumper = $this->newDumpBackup(
577 [ '--output', 'gzip:' . $fname ],
578 $this->pageId1,
579 $this->pageId4 + 1
580 );
581
582 // Performing the dump
583 $dumper->dump( WikiExporter::CURRENT, WikiExporter::STUB );
584
585 // Checking the dumped data
586 $this->gunzip( $fname );
587
588 $asserter = $this->getDumpAsserter();
589 $asserter->assertDumpStart( $fname );
590
591 // Page 1
592 $asserter->assertPageStart(
593 $this->pageId1,
594 $this->namespace,
595 $this->pageTitle1->getPrefixedText()
596 );
597 $asserter->assertRevision(
598 $this->revId1_1,
599 "BackupDumperTestP1Summary1",
600 $this->textId1_1,
601 23,
602 "0bolhl6ol7i6x0e7yq91gxgaan39j87"
603 );
604 $asserter->assertPageEnd();
605
606 // Page 2
607 $asserter->assertPageStart(
608 $this->pageId2,
609 $this->namespace,
610 $this->pageTitle2->getPrefixedText()
611 );
612 $asserter->assertRevision(
613 $this->revId2_4,
614 "BackupDumperTestP2Summary4 extra",
615 $this->textId2_4,
616 44,
617 "6o1ciaxa6pybnqprmungwofc4lv00wv",
618 false,
619 $this->revId2_3
620 );
621 $asserter->assertPageEnd();
622
623 // Page 3
624 // -> Page is marked deleted. Hence not visible
625
626 // Page 4
627 $asserter->assertPageStart(
628 $this->pageId4,
629 $this->talk_namespace,
630 $this->pageTitle4->getPrefixedText()
631 );
632 $asserter->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1",
633 $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe" );
634 $asserter->assertPageEnd();
635
636 $asserter->assertDumpEnd();
637 }
638
639 /**
640 * xmldumps-backup typically performs a single dump that that writes
641 * out three files
642 * - gzipped stubs of everything (meta-history)
643 * - gzipped stubs of latest revisions of all pages (meta-current)
644 * - gzipped stubs of latest revisions of all pages of namespage 0
645 * (articles)
646 *
647 * We reproduce such a setup with our mini fixture, although we omit
648 * chunks, and all the other gimmicks of xmldumps-backup.
649 *
650 * @dataProvider schemaVersionProvider
651 */
652 function testXmlDumpsBackupUseCase( $schemaVersion ) {
653 $this->checkHasGzip();
654
655 $fnameMetaHistory = $this->getNewTempFile();
656 $fnameMetaCurrent = $this->getNewTempFile();
657 $fnameArticles = $this->getNewTempFile();
658
659 $dumper = $this->newDumpBackup(
660 [ "--full", "--stub", "--output=gzip:" . $fnameMetaHistory,
661 "--output=gzip:" . $fnameMetaCurrent, "--filter=latest",
662 "--output=gzip:" . $fnameArticles, "--filter=latest",
663 "--filter=notalk", "--filter=namespace:!NS_USER",
664 "--reporting=1000", '--schema-version', $schemaVersion
665 ],
666 $this->pageId1,
667 $this->pageId4 + 1
668 );
669 $dumper->reporting = true;
670
671 // xmldumps-backup uses reporting. We will not check the exact reported
672 // message, as they are dependent on the processing power of the used
673 // computer. We only check that reporting does not crash the dumping
674 // and that something is reported
675 $dumper->stderr = fopen( 'php://output', 'a' );
676 if ( $dumper->stderr === false ) {
677 $this->fail( "Could not open stream for stderr" );
678 }
679
680 // Performing the dump
681 $dumper->dump( WikiExporter::FULL, WikiExporter::STUB );
682
683 $this->assertTrue( fclose( $dumper->stderr ), "Closing stderr handle" );
684
685 // Checking meta-history -------------------------------------------------
686
687 $this->gunzip( $fnameMetaHistory );
688 $this->assertDumpSchema( $fnameMetaHistory, $this->getXmlSchemaPath( $schemaVersion ) );
689
690 $asserter = $this->getDumpAsserter( $schemaVersion );
691 $asserter->assertDumpStart( $fnameMetaHistory );
692
693 // Page 1
694 $asserter->assertPageStart(
695 $this->pageId1,
696 $this->namespace,
697 $this->pageTitle1->getPrefixedText()
698 );
699 $asserter->assertRevision(
700 $this->revId1_1,
701 "BackupDumperTestP1Summary1",
702 $this->textId1_1,
703 23,
704 "0bolhl6ol7i6x0e7yq91gxgaan39j87"
705 );
706 $asserter->assertPageEnd();
707
708 // Page 2
709 $asserter->assertPageStart(
710 $this->pageId2,
711 $this->namespace,
712 $this->pageTitle2->getPrefixedText()
713 );
714 $asserter->assertRevision(
715 $this->revId2_1,
716 "BackupDumperTestP2Summary1",
717 $this->textId2_1,
718 23,
719 "jprywrymfhysqllua29tj3sc7z39dl2"
720 );
721 $asserter->assertRevision(
722 $this->revId2_2,
723 "BackupDumperTestP2Summary2",
724 null, // deleted!
725 false, // deleted!
726 null, // deleted!
727 false, // deleted!
728 $this->revId2_1
729 );
730 $asserter->assertRevision(
731 $this->revId2_3,
732 "BackupDumperTestP2Summary3",
733 $this->textId2_3,
734 23,
735 "jfunqmh1ssfb8rs43r19w98k28gg56r",
736 false,
737 $this->revId2_2
738 );
739 $asserter->assertRevision(
740 $this->revId2_4,
741 "BackupDumperTestP2Summary4 extra",
742 $this->textId2_4,
743 44,
744 "6o1ciaxa6pybnqprmungwofc4lv00wv",
745 false,
746 $this->revId2_3
747 );
748 $asserter->assertPageEnd();
749
750 // Page 3
751 // -> Page is marked deleted. Hence not visible
752
753 // Page 4
754 $asserter->assertPageStart(
755 $this->pageId4,
756 $this->talk_namespace,
757 $this->pageTitle4->getPrefixedText( $schemaVersion )
758 );
759 $asserter->assertRevision(
760 $this->revId4_1,
761 "Talk BackupDumperTestP1 Summary1",
762 $this->textId4_1,
763 35,
764 "nktofwzd0tl192k3zfepmlzxoax1lpe"
765 );
766 $asserter->assertPageEnd();
767
768 $asserter->assertDumpEnd();
769
770 // Checking meta-current -------------------------------------------------
771
772 $this->gunzip( $fnameMetaCurrent );
773 $this->assertDumpSchema( $fnameMetaCurrent, $this->getXmlSchemaPath( $schemaVersion ) );
774
775 $asserter = $this->getDumpAsserter( $schemaVersion );
776 $asserter->assertDumpStart( $fnameMetaCurrent );
777
778 // Page 1
779 $asserter->assertPageStart(
780 $this->pageId1,
781 $this->namespace,
782 $this->pageTitle1->getPrefixedText()
783 );
784 $asserter->assertRevision(
785 $this->revId1_1,
786 "BackupDumperTestP1Summary1",
787 $this->textId1_1,
788 23,
789 "0bolhl6ol7i6x0e7yq91gxgaan39j87"
790 );
791 $asserter->assertPageEnd();
792
793 // Page 2
794 $asserter->assertPageStart(
795 $this->pageId2,
796 $this->namespace,
797 $this->pageTitle2->getPrefixedText()
798 );
799 $asserter->assertRevision(
800 $this->revId2_4,
801 "BackupDumperTestP2Summary4 extra",
802 $this->textId2_4,
803 44,
804 "6o1ciaxa6pybnqprmungwofc4lv00wv",
805 false,
806 $this->revId2_3
807 );
808 $asserter->assertPageEnd();
809
810 // Page 3
811 // -> Page is marked deleted. Hence not visible
812
813 // Page 4
814 $asserter->assertPageStart(
815 $this->pageId4,
816 $this->talk_namespace,
817 $this->pageTitle4->getPrefixedText()
818 );
819 $asserter->assertRevision(
820 $this->revId4_1,
821 "Talk BackupDumperTestP1 Summary1",
822 $this->textId4_1,
823 35,
824 "nktofwzd0tl192k3zfepmlzxoax1lpe"
825 );
826 $asserter->assertPageEnd();
827
828 $asserter->assertDumpEnd();
829
830 // Checking articles -------------------------------------------------
831
832 $this->gunzip( $fnameArticles );
833 $this->assertDumpSchema( $fnameArticles, $this->getXmlSchemaPath( $schemaVersion ) );
834
835 $asserter = $this->getDumpAsserter( $schemaVersion );
836 $asserter->assertDumpStart( $fnameArticles );
837
838 // Page 1
839 $asserter->assertPageStart(
840 $this->pageId1,
841 $this->namespace,
842 $this->pageTitle1->getPrefixedText()
843 );
844 $asserter->assertRevision(
845 $this->revId1_1,
846 "BackupDumperTestP1Summary1",
847 $this->textId1_1,
848 23,
849 "0bolhl6ol7i6x0e7yq91gxgaan39j87"
850 );
851 $asserter->assertPageEnd();
852
853 // Page 2
854 $asserter->assertPageStart(
855 $this->pageId2,
856 $this->namespace,
857 $this->pageTitle2->getPrefixedText()
858 );
859 $asserter->assertRevision(
860 $this->revId2_4,
861 "BackupDumperTestP2Summary4 extra",
862 $this->textId2_4,
863 44,
864 "6o1ciaxa6pybnqprmungwofc4lv00wv",
865 false,
866 $this->revId2_3
867 );
868 $asserter->assertPageEnd();
869
870 // Page 3
871 // -> Page is marked deleted. Hence not visible
872
873 // Page 4
874 // -> Page is not in $this->namespace. Hence not visible
875
876 $asserter->assertDumpEnd();
877
878 $this->expectETAOutput();
879 }
880 }