3 use Wikimedia\TestingAccessWrapper
;
6 * Test cases in RevisionTest should not interact with the Database.
7 * For test cases that need Database interaction see RevisionDbTestBase.
9 class RevisionTest
extends MediaWikiTestCase
{
11 public function provideConstructFromArray() {
12 yield
'with text' => [
14 'text' => 'hello world.',
15 'content_model' => CONTENT_MODEL_JAVASCRIPT
18 yield
'with content' => [
20 'content' => new JavaScriptContent( 'hellow world.' )
26 * @dataProvider provideConstructFromArray
27 * @covers Revision::__construct
28 * @covers Revision::constructFromRowArray
30 public function testConstructFromArray( array $rowArray ) {
31 $rev = new Revision( $rowArray );
32 $this->assertNotNull( $rev->getContent(), 'no content object available' );
33 $this->assertEquals( CONTENT_MODEL_JAVASCRIPT
, $rev->getContent()->getModel() );
34 $this->assertEquals( CONTENT_MODEL_JAVASCRIPT
, $rev->getContentModel() );
37 public function provideConstructFromArrayThrowsExceptions() {
38 yield
'content and text_id both not empty' => [
40 'content' => new WikitextContent( 'GOAT' ),
41 'text_id' => 'someid',
43 new MWException( "Text already stored in external store (id someid), " .
44 "can't serialize content object" )
46 yield
'with bad content object (class)' => [
47 [ 'content' => new stdClass() ],
48 new MWException( '`content` field must contain a Content object.' )
50 yield
'with bad content object (string)' => [
51 [ 'content' => 'ImAGoat' ],
52 new MWException( '`content` field must contain a Content object.' )
54 yield
'bad row format' => [
55 'imastring, not a row',
56 new MWException( 'Revision constructor passed invalid row format.' )
61 * @dataProvider provideConstructFromArrayThrowsExceptions
62 * @covers Revision::__construct
63 * @covers Revision::constructFromRowArray
65 public function testConstructFromArrayThrowsExceptions( $rowArray, Exception
$expectedException ) {
66 $this->setExpectedException(
67 get_class( $expectedException ),
68 $expectedException->getMessage(),
69 $expectedException->getCode()
71 new Revision( $rowArray );
74 public function provideConstructFromRow() {
75 yield
'Full construction' => [
80 'rev_timestamp' => '20171017114835',
81 'rev_user_text' => '127.0.0.1',
83 'rev_minor_edit' => '0',
86 'rev_parent_id' => '1',
87 'rev_sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
88 'rev_comment_text' => 'Goat Comment!',
89 'rev_comment_data' => null,
90 'rev_comment_cid' => null,
91 'rev_content_format' => 'GOATFORMAT',
92 'rev_content_model' => 'GOATMODEL',
94 function ( RevisionTest
$testCase, Revision
$rev ) {
95 $testCase->assertSame( 2, $rev->getId() );
96 $testCase->assertSame( 1, $rev->getPage() );
97 $testCase->assertSame( 2, $rev->getTextId() );
98 $testCase->assertSame( '20171017114835', $rev->getTimestamp() );
99 $testCase->assertSame( '127.0.0.1', $rev->getUserText() );
100 $testCase->assertSame( 0, $rev->getUser() );
101 $testCase->assertSame( false, $rev->isMinor() );
102 $testCase->assertSame( false, $rev->isDeleted( Revision
::DELETED_TEXT
) );
103 $testCase->assertSame( 46, $rev->getSize() );
104 $testCase->assertSame( 1, $rev->getParentId() );
105 $testCase->assertSame( 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z', $rev->getSha1() );
106 $testCase->assertSame( 'Goat Comment!', $rev->getComment() );
107 $testCase->assertSame( 'GOATFORMAT', $rev->getContentFormat() );
108 $testCase->assertSame( 'GOATMODEL', $rev->getContentModel() );
111 yield
'null fields' => [
115 'rev_text_id' => '2',
116 'rev_timestamp' => '20171017114835',
117 'rev_user_text' => '127.0.0.1',
119 'rev_minor_edit' => '0',
120 'rev_deleted' => '0',
121 'rev_comment_text' => 'Goat Comment!',
122 'rev_comment_data' => null,
123 'rev_comment_cid' => null,
125 function ( RevisionTest
$testCase, Revision
$rev ) {
126 $testCase->assertNull( $rev->getSize() );
127 $testCase->assertNull( $rev->getParentId() );
128 $testCase->assertNull( $rev->getSha1() );
129 $testCase->assertSame( 'text/x-wiki', $rev->getContentFormat() );
130 $testCase->assertSame( 'wikitext', $rev->getContentModel() );
136 * @dataProvider provideConstructFromRow
137 * @covers Revision::__construct
138 * @covers Revision::constructFromDbRowObject
140 public function testConstructFromRow( array $arrayData, $assertions ) {
141 $row = (object)$arrayData;
142 $rev = new Revision( $row );
143 $assertions( $this, $rev );
146 public function provideGetRevisionText() {
147 yield
'Generic test' => [
148 'This is a goat of revision text.',
151 'old_text' => 'This is a goat of revision text.',
156 public function provideGetId() {
168 * @dataProvider provideGetId
169 * @covers Revision::getId
171 public function testGetId( $rowArray, $expectedId ) {
172 $rev = new Revision( $rowArray );
173 $this->assertEquals( $expectedId, $rev->getId() );
176 public function provideSetId() {
177 yield
[ '123', 123 ];
182 * @dataProvider provideSetId
183 * @covers Revision::setId
185 public function testSetId( $input, $expected ) {
186 $rev = new Revision( [] );
187 $rev->setId( $input );
188 $this->assertSame( $expected, $rev->getId() );
191 public function provideSetUserIdAndName() {
192 yield
[ '123', 123, 'GOaT' ];
193 yield
[ 456, 456, 'GOaT' ];
197 * @dataProvider provideSetUserIdAndName
198 * @covers Revision::setUserIdAndName
200 public function testSetUserIdAndName( $inputId, $expectedId, $name ) {
201 $rev = new Revision( [] );
202 $rev->setUserIdAndName( $inputId, $name );
203 $this->assertSame( $expectedId, $rev->getUser( Revision
::RAW
) );
204 $this->assertEquals( $name, $rev->getUserText( Revision
::RAW
) );
207 public function provideGetTextId() {
209 yield
[ [ 'text_id' => '123' ], 123 ];
210 yield
[ [ 'text_id' => 456 ], 456 ];
214 * @dataProvider provideGetTextId
215 * @covers Revision::getTextId()
217 public function testGetTextId( $rowArray, $expected ) {
218 $rev = new Revision( $rowArray );
219 $this->assertSame( $expected, $rev->getTextId() );
222 public function provideGetParentId() {
224 yield
[ [ 'parent_id' => '123' ], 123 ];
225 yield
[ [ 'parent_id' => 456 ], 456 ];
229 * @dataProvider provideGetParentId
230 * @covers Revision::getParentId()
232 public function testGetParentId( $rowArray, $expected ) {
233 $rev = new Revision( $rowArray );
234 $this->assertSame( $expected, $rev->getParentId() );
238 * @covers Revision::getRevisionText
239 * @dataProvider provideGetRevisionText
241 public function testGetRevisionText( $expected, $rowData, $prefix = 'old_', $wiki = false ) {
244 Revision
::getRevisionText( (object)$rowData, $prefix, $wiki ) );
247 public function provideGetRevisionTextWithZlibExtension() {
248 yield
'Generic gzip test' => [
249 'This is a small goat of revision text.',
251 'old_flags' => 'gzip',
252 'old_text' => gzdeflate( 'This is a small goat of revision text.' ),
258 * @covers Revision::getRevisionText
259 * @dataProvider provideGetRevisionTextWithZlibExtension
261 public function testGetRevisionWithZlibExtension( $expected, $rowData ) {
262 $this->checkPHPExtension( 'zlib' );
263 $this->testGetRevisionText( $expected, $rowData );
266 public function provideGetRevisionTextWithLegacyEncoding() {
267 yield
'Utf8Native' => [
268 "Wiki est l'\xc3\xa9cole superieur !",
271 'old_flags' => 'utf-8',
272 'old_text' => "Wiki est l'\xc3\xa9cole superieur !",
275 yield
'Utf8Legacy' => [
276 "Wiki est l'\xc3\xa9cole superieur !",
280 'old_text' => "Wiki est l'\xe9cole superieur !",
286 * @covers Revision::getRevisionText
287 * @dataProvider provideGetRevisionTextWithLegacyEncoding
289 public function testGetRevisionWithLegacyEncoding( $expected, $encoding, $rowData ) {
290 $this->setMwGlobals( 'wgLegacyEncoding', $encoding );
291 $this->testGetRevisionText( $expected, $rowData );
294 public function provideGetRevisionTextWithGzipAndLegacyEncoding() {
297 * Do not set the external flag!
298 * Otherwise, getRevisionText will hit the live database (if ExternalStore is enabled)!
300 yield
'Utf8NativeGzip' => [
301 "Wiki est l'\xc3\xa9cole superieur !",
304 'old_flags' => 'gzip,utf-8',
305 'old_text' => gzdeflate( "Wiki est l'\xc3\xa9cole superieur !" ),
308 yield
'Utf8LegacyGzip' => [
309 "Wiki est l'\xc3\xa9cole superieur !",
312 'old_flags' => 'gzip',
313 'old_text' => gzdeflate( "Wiki est l'\xe9cole superieur !" ),
319 * @covers Revision::getRevisionText
320 * @dataProvider provideGetRevisionTextWithGzipAndLegacyEncoding
322 public function testGetRevisionWithGzipAndLegacyEncoding( $expected, $encoding, $rowData ) {
323 $this->checkPHPExtension( 'zlib' );
324 $this->setMwGlobals( 'wgLegacyEncoding', $encoding );
325 $this->testGetRevisionText( $expected, $rowData );
329 * @covers Revision::compressRevisionText
331 public function testCompressRevisionTextUtf8() {
333 $row->old_text
= "Wiki est l'\xc3\xa9cole superieur !";
334 $row->old_flags
= Revision
::compressRevisionText( $row->old_text
);
335 $this->assertTrue( false !== strpos( $row->old_flags
, 'utf-8' ),
336 "Flags should contain 'utf-8'" );
337 $this->assertFalse( false !== strpos( $row->old_flags
, 'gzip' ),
338 "Flags should not contain 'gzip'" );
339 $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
340 $row->old_text
, "Direct check" );
341 $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
342 Revision
::getRevisionText( $row ), "getRevisionText" );
346 * @covers Revision::compressRevisionText
348 public function testCompressRevisionTextUtf8Gzip() {
349 $this->checkPHPExtension( 'zlib' );
350 $this->setMwGlobals( 'wgCompressRevisions', true );
353 $row->old_text
= "Wiki est l'\xc3\xa9cole superieur !";
354 $row->old_flags
= Revision
::compressRevisionText( $row->old_text
);
355 $this->assertTrue( false !== strpos( $row->old_flags
, 'utf-8' ),
356 "Flags should contain 'utf-8'" );
357 $this->assertTrue( false !== strpos( $row->old_flags
, 'gzip' ),
358 "Flags should contain 'gzip'" );
359 $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
360 gzinflate( $row->old_text
), "Direct check" );
361 $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
362 Revision
::getRevisionText( $row ), "getRevisionText" );
365 public function provideFetchFromConds() {
367 yield
[ Revision
::READ_LOCKING
, [ 'FOR UPDATE' ] ];
371 * @dataProvider provideFetchFromConds
372 * @covers Revision::fetchFromConds
374 public function testFetchFromConds( $flags, array $options ) {
375 $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_OLD
);
376 $conditions = [ 'conditionsArray' ];
378 $db = $this->getMock( IDatabase
::class );
379 $db->expects( $this->once() )
380 ->method( 'selectRow' )
382 $this->equalTo( [ 'revision', 'page', 'user' ] ),
383 // We don't really care about the fields are they come from the selectField methods
384 $this->isType( 'array' ),
385 $this->equalTo( $conditions ),
387 $this->equalTo( 'Revision::fetchFromConds' ),
388 $this->equalTo( $options ),
389 // We don't really care about the join conds are they come from the joinCond methods
390 $this->isType( 'array' )
392 ->willReturn( 'RETURNVALUE' );
394 $wrapper = TestingAccessWrapper
::newFromClass( Revision
::class );
395 $result = $wrapper->fetchFromConds( $db, $conditions, $flags );
397 $this->assertEquals( 'RETURNVALUE', $result );
400 public function provideDecompressRevisionText() {
401 yield
'(no legacy encoding), false in false out' => [ false, false, [], false ];
402 yield
'(no legacy encoding), empty in empty out' => [ false, '', [], '' ];
403 yield
'(no legacy encoding), empty in empty out' => [ false, 'A', [], 'A' ];
404 yield
'(no legacy encoding), string in with gzip flag returns string' => [
405 // gzip string below generated with gzdeflate( 'AAAABBAAA' )
406 false, "sttttr\002\022\000", [ 'gzip' ], 'AAAABBAAA',
408 yield
'(no legacy encoding), string in with object flag returns false' => [
409 // gzip string below generated with serialize( 'JOJO' )
410 false, "s:4:\"JOJO\";", [ 'object' ], false,
412 yield
'(no legacy encoding), serialized object in with object flag returns string' => [
414 // Using a TitleValue object as it has a getText method (which is needed)
415 serialize( new TitleValue( 0, 'HHJJDDFF' ) ),
419 yield
'(no legacy encoding), serialized object in with object & gzip flag returns string' => [
421 // Using a TitleValue object as it has a getText method (which is needed)
422 gzdeflate( serialize( new TitleValue( 0, '8219JJJ840' ) ) ),
423 [ 'object', 'gzip' ],
426 yield
'(ISO-8859-1 encoding), string in string out' => [
428 iconv( 'utf8', 'ISO-8859-1', "1®Àþ1" ),
432 yield
'(ISO-8859-1 encoding), serialized object in with gzip flags returns string' => [
434 gzdeflate( iconv( 'utf8', 'ISO-8859-1', "4®Àþ4" ) ),
438 yield
'(ISO-8859-1 encoding), serialized object in with object flags returns string' => [
440 serialize( new TitleValue( 0, iconv( 'utf8', 'ISO-8859-1', "3®Àþ3" ) ) ),
444 yield
'(ISO-8859-1 encoding), serialized object in with object & gzip flags returns string' => [
446 gzdeflate( serialize( new TitleValue( 0, iconv( 'utf8', 'ISO-8859-1', "2®Àþ2" ) ) ) ),
447 [ 'gzip', 'object' ],
453 * @dataProvider provideDecompressRevisionText
454 * @covers Revision::decompressRevisionText
456 * @param bool $legacyEncoding
458 * @param array $flags
459 * @param mixed $expected
461 public function testDecompressRevisionText( $legacyEncoding, $text, $flags, $expected ) {
462 $this->setMwGlobals( 'wgLegacyEncoding', $legacyEncoding );
463 $this->setMwGlobals( 'wgLanguageCode', 'en' );
466 Revision
::decompressRevisionText( $text, $flags )
471 * @covers Revision::getRevisionText
473 public function testGetRevisionText_returnsFalseWhenNoTextField() {
474 $this->assertFalse( Revision
::getRevisionText( new stdClass() ) );
477 public function provideTestGetRevisionText_returnsDecompressedTextFieldWhenNotExternal() {
478 yield
'Just text' => [
479 (object)[ 'old_text' => 'SomeText' ],
483 // gzip string below generated with gzdeflate( 'AAAABBAAA' )
484 yield
'gzip text' => [
486 'old_text' => "sttttr\002\022\000",
487 'old_flags' => 'gzip'
492 yield
'gzip text and different prefix' => [
494 'jojo_text' => "sttttr\002\022\000",
495 'jojo_flags' => 'gzip'
503 * @dataProvider provideTestGetRevisionText_returnsDecompressedTextFieldWhenNotExternal
504 * @covers Revision::getRevisionText
506 public function testGetRevisionText_returnsDecompressedTextFieldWhenNotExternal(
511 $this->assertSame( $expected, Revision
::getRevisionText( $row, $prefix ) );
514 public function provideTestGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts() {
515 yield
'Just some text' => [ 'someNonUrlText' ];
516 yield
'No second URL part' => [ 'someProtocol://' ];
520 * @dataProvider provideTestGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts
521 * @covers Revision::getRevisionText
523 public function testGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts(
527 Revision
::getRevisionText(
530 'old_flags' => 'external',
537 * @covers Revision::getRevisionText
539 public function testGetRevisionText_external_noOldId() {
541 'ExternalStoreFactory',
542 new ExternalStoreFactory( [ 'ForTesting' ] )
546 Revision
::getRevisionText(
548 'old_text' => 'ForTesting://cluster1/12345',
549 'old_flags' => 'external,gzip',
556 * @covers Revision::getRevisionText
558 public function testGetRevisionText_external_oldId() {
559 $cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
560 $this->setService( 'MainWANObjectCache', $cache );
562 'ExternalStoreFactory',
563 new ExternalStoreFactory( [ 'ForTesting' ] )
566 $cacheKey = $cache->makeKey( 'revisiontext', 'textid', '7777' );
570 Revision
::getRevisionText(
572 'old_text' => 'ForTesting://cluster1/12345',
573 'old_flags' => 'external,gzip',
578 $this->assertSame( 'AAAABBAAA', $cache->get( $cacheKey ) );
582 * @covers Revision::userJoinCond
584 public function testUserJoinCond() {
585 $this->hideDeprecated( 'Revision::userJoinCond' );
587 [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
588 Revision
::userJoinCond()
593 * @covers Revision::pageJoinCond
595 public function testPageJoinCond() {
596 $this->hideDeprecated( 'Revision::pageJoinCond' );
598 [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
599 Revision
::pageJoinCond()
603 public function provideSelectFields() {
618 'rev_comment_text' => 'rev_comment',
619 'rev_comment_data' => 'NULL',
620 'rev_comment_cid' => 'NULL',
621 'rev_content_format',
639 'rev_comment_text' => 'rev_comment',
640 'rev_comment_data' => 'NULL',
641 'rev_comment_cid' => 'NULL',
647 * @dataProvider provideSelectFields
648 * @covers Revision::selectFields
649 * @todo a true unit test would mock CommentStore
651 public function testSelectFields( $contentHandlerUseDB, $expected ) {
652 $this->hideDeprecated( 'Revision::selectFields' );
653 $this->setMwGlobals( 'wgContentHandlerUseDB', $contentHandlerUseDB );
654 $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_OLD
);
655 $this->assertEquals( $expected, Revision
::selectFields() );
658 public function provideSelectArchiveFields() {
675 'ar_comment_text' => 'ar_comment',
676 'ar_comment_data' => 'NULL',
677 'ar_comment_cid' => 'NULL',
698 'ar_comment_text' => 'ar_comment',
699 'ar_comment_data' => 'NULL',
700 'ar_comment_cid' => 'NULL',
706 * @dataProvider provideSelectArchiveFields
707 * @covers Revision::selectArchiveFields
708 * @todo a true unit test would mock CommentStore
710 public function testSelectArchiveFields( $contentHandlerUseDB, $expected ) {
711 $this->hideDeprecated( 'Revision::selectArchiveFields' );
712 $this->setMwGlobals( 'wgContentHandlerUseDB', $contentHandlerUseDB );
713 $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_OLD
);
714 $this->assertEquals( $expected, Revision
::selectArchiveFields() );
718 * @covers Revision::selectTextFields
720 public function testSelectTextFields() {
721 $this->hideDeprecated( 'Revision::selectTextFields' );
727 Revision
::selectTextFields()
732 * @covers Revision::selectPageFields
734 public function testSelectPageFields() {
735 $this->hideDeprecated( 'Revision::selectPageFields' );
745 Revision
::selectPageFields()
750 * @covers Revision::selectUserFields
752 public function testSelectUserFields() {
753 $this->hideDeprecated( 'Revision::selectUserFields' );
758 Revision
::selectUserFields()
762 public function provideGetArchiveQueryInfo() {
763 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage OLD' => [
765 'wgContentHandlerUseDB' => false,
766 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
769 'tables' => [ 'archive' ],
784 'ar_comment_text' => 'ar_comment',
785 'ar_comment_data' => 'NULL',
786 'ar_comment_cid' => 'NULL',
791 yield
'wgContentHandlerUseDB true, wgCommentTableSchemaMigrationStage OLD' => [
793 'wgContentHandlerUseDB' => true,
794 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
797 'tables' => [ 'archive' ],
812 'ar_comment_text' => 'ar_comment',
813 'ar_comment_data' => 'NULL',
814 'ar_comment_cid' => 'NULL',
821 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage WRITE_BOTH' => [
823 'wgContentHandlerUseDB' => false,
824 'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH
,
829 'comment_ar_comment' => 'comment',
845 'ar_comment_text' => 'COALESCE( comment_ar_comment.comment_text, ar_comment )',
846 'ar_comment_data' => 'comment_ar_comment.comment_data',
847 'ar_comment_cid' => 'comment_ar_comment.comment_id',
850 'comment_ar_comment' => [
852 'comment_ar_comment.comment_id = ar_comment_id',
857 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage WRITE_NEW' => [
859 'wgContentHandlerUseDB' => false,
860 'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_NEW
,
865 'comment_ar_comment' => 'comment',
881 'ar_comment_text' => 'COALESCE( comment_ar_comment.comment_text, ar_comment )',
882 'ar_comment_data' => 'comment_ar_comment.comment_data',
883 'ar_comment_cid' => 'comment_ar_comment.comment_id',
886 'comment_ar_comment' => [
888 'comment_ar_comment.comment_id = ar_comment_id',
893 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage NEW' => [
895 'wgContentHandlerUseDB' => false,
896 'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW
,
901 'comment_ar_comment' => 'comment',
917 'ar_comment_text' => 'comment_ar_comment.comment_text',
918 'ar_comment_data' => 'comment_ar_comment.comment_data',
919 'ar_comment_cid' => 'comment_ar_comment.comment_id',
922 'comment_ar_comment' => [
924 'comment_ar_comment.comment_id = ar_comment_id',
932 * @covers Revision::getArchiveQueryInfo
933 * @dataProvider provideGetArchiveQueryInfo
935 public function testGetArchiveQueryInfo( $globals, $expected ) {
936 $this->setMwGlobals( $globals );
939 Revision
::getArchiveQueryInfo()
943 public function provideGetQueryInfo() {
944 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage OLD, opts none' => [
946 'wgContentHandlerUseDB' => false,
947 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
951 'tables' => [ 'revision' ],
964 'rev_comment_text' => 'rev_comment',
965 'rev_comment_data' => 'NULL',
966 'rev_comment_cid' => 'NULL',
971 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage OLD, opts page' => [
973 'wgContentHandlerUseDB' => false,
974 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
978 'tables' => [ 'revision', 'page' ],
991 'rev_comment_text' => 'rev_comment',
992 'rev_comment_data' => 'NULL',
993 'rev_comment_cid' => 'NULL',
1004 [ 'page_id = rev_page' ],
1009 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage OLD, opts user' => [
1011 'wgContentHandlerUseDB' => false,
1012 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
1016 'tables' => [ 'revision', 'user' ],
1029 'rev_comment_text' => 'rev_comment',
1030 'rev_comment_data' => 'NULL',
1031 'rev_comment_cid' => 'NULL',
1039 'user_id = rev_user',
1045 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage OLD, opts text' => [
1047 'wgContentHandlerUseDB' => false,
1048 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
1052 'tables' => [ 'revision', 'text' ],
1065 'rev_comment_text' => 'rev_comment',
1066 'rev_comment_data' => 'NULL',
1067 'rev_comment_cid' => 'NULL',
1074 [ 'rev_text_id=old_id' ],
1079 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage OLD, opts 3' => [
1081 'wgContentHandlerUseDB' => false,
1082 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
1084 [ 'text', 'page', 'user' ],
1086 'tables' => [ 'revision', 'page', 'user', 'text' ],
1099 'rev_comment_text' => 'rev_comment',
1100 'rev_comment_data' => 'NULL',
1101 'rev_comment_cid' => 'NULL',
1115 [ 'page_id = rev_page' ],
1121 'user_id = rev_user',
1126 [ 'rev_text_id=old_id' ],
1131 yield
'wgContentHandlerUseDB true, wgCommentTableSchemaMigrationStage OLD, opts none' => [
1133 'wgContentHandlerUseDB' => true,
1134 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
1138 'tables' => [ 'revision' ],
1151 'rev_comment_text' => 'rev_comment',
1152 'rev_comment_data' => 'NULL',
1153 'rev_comment_cid' => 'NULL',
1154 'rev_content_format',
1155 'rev_content_model',
1160 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage WRITE_BOTH, opts none' => [
1162 'wgContentHandlerUseDB' => false,
1163 'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH
,
1169 'temp_rev_comment' => 'revision_comment_temp',
1170 'comment_rev_comment' => 'comment',
1184 'rev_comment_text' => 'COALESCE( comment_rev_comment.comment_text, rev_comment )',
1185 'rev_comment_data' => 'comment_rev_comment.comment_data',
1186 'rev_comment_cid' => 'comment_rev_comment.comment_id',
1189 'temp_rev_comment' => [
1191 'temp_rev_comment.revcomment_rev = rev_id',
1193 'comment_rev_comment' => [
1195 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id',
1200 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage WRITE_NEW, opts none' => [
1202 'wgContentHandlerUseDB' => false,
1203 'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_NEW
,
1209 'temp_rev_comment' => 'revision_comment_temp',
1210 'comment_rev_comment' => 'comment',
1224 'rev_comment_text' => 'COALESCE( comment_rev_comment.comment_text, rev_comment )',
1225 'rev_comment_data' => 'comment_rev_comment.comment_data',
1226 'rev_comment_cid' => 'comment_rev_comment.comment_id',
1229 'temp_rev_comment' => [
1231 'temp_rev_comment.revcomment_rev = rev_id',
1233 'comment_rev_comment' => [
1235 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id',
1240 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage NEW, opts none' => [
1242 'wgContentHandlerUseDB' => false,
1243 'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW
,
1249 'temp_rev_comment' => 'revision_comment_temp',
1250 'comment_rev_comment' => 'comment',
1264 'rev_comment_text' => 'comment_rev_comment.comment_text',
1265 'rev_comment_data' => 'comment_rev_comment.comment_data',
1266 'rev_comment_cid' => 'comment_rev_comment.comment_id',
1269 'temp_rev_comment' => [
1271 'temp_rev_comment.revcomment_rev = rev_id',
1273 'comment_rev_comment' => [
1275 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id',
1283 * @covers Revision::getQueryInfo
1284 * @dataProvider provideGetQueryInfo
1286 public function testGetQueryInfo( $globals, $options, $expected ) {
1287 $this->setMwGlobals( $globals );
1288 $this->assertEquals(
1290 Revision
::getQueryInfo( $options )