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 $conditions = [ 'conditionsArray' ];
377 $db = $this->getMock( IDatabase
::class );
378 $db->expects( $this->once() )
379 ->method( 'selectRow' )
381 $this->equalTo( [ 'revision', 'page', 'user' ] ),
382 // We don't really care about the fields are they come from the selectField methods
383 $this->isType( 'array' ),
384 $this->equalTo( $conditions ),
386 $this->equalTo( 'Revision::fetchFromConds' ),
387 $this->equalTo( $options ),
388 // We don't really care about the join conds are they come from the joinCond methods
389 $this->isType( 'array' )
391 ->willReturn( 'RETURNVALUE' );
393 $wrapper = TestingAccessWrapper
::newFromClass( Revision
::class );
394 $result = $wrapper->fetchFromConds( $db, $conditions, $flags );
396 $this->assertEquals( 'RETURNVALUE', $result );
399 public function provideDecompressRevisionText() {
400 yield
'(no legacy encoding), false in false out' => [ false, false, [], false ];
401 yield
'(no legacy encoding), empty in empty out' => [ false, '', [], '' ];
402 yield
'(no legacy encoding), empty in empty out' => [ false, 'A', [], 'A' ];
403 yield
'(no legacy encoding), string in with gzip flag returns string' => [
404 // gzip string below generated with gzdeflate( 'AAAABBAAA' )
405 false, "sttttr\002\022\000", [ 'gzip' ], 'AAAABBAAA',
407 yield
'(no legacy encoding), string in with object flag returns false' => [
408 // gzip string below generated with serialize( 'JOJO' )
409 false, "s:4:\"JOJO\";", [ 'object' ], false,
411 yield
'(no legacy encoding), serialized object in with object flag returns string' => [
413 // Using a TitleValue object as it has a getText method (which is needed)
414 serialize( new TitleValue( 0, 'HHJJDDFF' ) ),
418 yield
'(no legacy encoding), serialized object in with object & gzip flag returns string' => [
420 // Using a TitleValue object as it has a getText method (which is needed)
421 gzdeflate( serialize( new TitleValue( 0, '8219JJJ840' ) ) ),
422 [ 'object', 'gzip' ],
425 yield
'(ISO-8859-1 encoding), string in string out' => [
427 iconv( 'utf8', 'ISO-8859-1', "1®Àþ1" ),
431 yield
'(ISO-8859-1 encoding), serialized object in with gzip flags returns string' => [
433 gzdeflate( iconv( 'utf8', 'ISO-8859-1', "4®Àþ4" ) ),
437 yield
'(ISO-8859-1 encoding), serialized object in with object flags returns string' => [
439 serialize( new TitleValue( 0, iconv( 'utf8', 'ISO-8859-1', "3®Àþ3" ) ) ),
443 yield
'(ISO-8859-1 encoding), serialized object in with object & gzip flags returns string' => [
445 gzdeflate( serialize( new TitleValue( 0, iconv( 'utf8', 'ISO-8859-1', "2®Àþ2" ) ) ) ),
446 [ 'gzip', 'object' ],
452 * @dataProvider provideDecompressRevisionText
453 * @covers Revision::decompressRevisionText
455 * @param bool $legacyEncoding
457 * @param array $flags
458 * @param mixed $expected
460 public function testDecompressRevisionText( $legacyEncoding, $text, $flags, $expected ) {
461 $this->setMwGlobals( 'wgLegacyEncoding', $legacyEncoding );
462 $this->setMwGlobals( 'wgLanguageCode', 'en' );
465 Revision
::decompressRevisionText( $text, $flags )
470 * @covers Revision::getRevisionText
472 public function testGetRevisionText_returnsFalseWhenNoTextField() {
473 $this->assertFalse( Revision
::getRevisionText( new stdClass() ) );
476 public function provideTestGetRevisionText_returnsDecompressedTextFieldWhenNotExternal() {
477 yield
'Just text' => [
478 (object)[ 'old_text' => 'SomeText' ],
482 // gzip string below generated with gzdeflate( 'AAAABBAAA' )
483 yield
'gzip text' => [
485 'old_text' => "sttttr\002\022\000",
486 'old_flags' => 'gzip'
491 yield
'gzip text and different prefix' => [
493 'jojo_text' => "sttttr\002\022\000",
494 'jojo_flags' => 'gzip'
502 * @dataProvider provideTestGetRevisionText_returnsDecompressedTextFieldWhenNotExternal
503 * @covers Revision::getRevisionText
505 public function testGetRevisionText_returnsDecompressedTextFieldWhenNotExternal(
510 $this->assertSame( $expected, Revision
::getRevisionText( $row, $prefix ) );
513 public function provideTestGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts() {
514 yield
'Just some text' => [ 'someNonUrlText' ];
515 yield
'No second URL part' => [ 'someProtocol://' ];
519 * @dataProvider provideTestGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts
520 * @covers Revision::getRevisionText
522 public function testGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts(
526 Revision
::getRevisionText(
529 'old_flags' => 'external',
536 * @covers Revision::getRevisionText
538 public function testGetRevisionText_external_noOldId() {
540 'ExternalStoreFactory',
541 new ExternalStoreFactory( [ 'ForTesting' ] )
545 Revision
::getRevisionText(
547 'old_text' => 'ForTesting://cluster1/12345',
548 'old_flags' => 'external,gzip',
555 * @covers Revision::getRevisionText
557 public function testGetRevisionText_external_oldId() {
558 $cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
559 $this->setService( 'MainWANObjectCache', $cache );
561 'ExternalStoreFactory',
562 new ExternalStoreFactory( [ 'ForTesting' ] )
565 $cacheKey = $cache->makeKey( 'revisiontext', 'textid', '7777' );
569 Revision
::getRevisionText(
571 'old_text' => 'ForTesting://cluster1/12345',
572 'old_flags' => 'external,gzip',
577 $this->assertSame( 'AAAABBAAA', $cache->get( $cacheKey ) );
581 * @covers Revision::userJoinCond
583 public function testUserJoinCond() {
584 $this->hideDeprecated( 'Revision::userJoinCond' );
586 [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
587 Revision
::userJoinCond()
592 * @covers Revision::pageJoinCond
594 public function testPageJoinCond() {
595 $this->hideDeprecated( 'Revision::pageJoinCond' );
597 [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
598 Revision
::pageJoinCond()
602 public function provideSelectFields() {
617 'rev_comment_text' => 'rev_comment',
618 'rev_comment_data' => 'NULL',
619 'rev_comment_cid' => 'NULL',
620 'rev_content_format',
638 'rev_comment_text' => 'rev_comment',
639 'rev_comment_data' => 'NULL',
640 'rev_comment_cid' => 'NULL',
646 * @dataProvider provideSelectFields
647 * @covers Revision::selectFields
648 * @todo a true unit test would mock CommentStore
650 public function testSelectFields( $contentHandlerUseDB, $expected ) {
651 $this->hideDeprecated( 'Revision::selectFields' );
652 $this->setMwGlobals( 'wgContentHandlerUseDB', $contentHandlerUseDB );
653 $this->assertEquals( $expected, Revision
::selectFields() );
656 public function provideSelectArchiveFields() {
673 'ar_comment_text' => 'ar_comment',
674 'ar_comment_data' => 'NULL',
675 'ar_comment_cid' => 'NULL',
696 'ar_comment_text' => 'ar_comment',
697 'ar_comment_data' => 'NULL',
698 'ar_comment_cid' => 'NULL',
704 * @dataProvider provideSelectArchiveFields
705 * @covers Revision::selectArchiveFields
706 * @todo a true unit test would mock CommentStore
708 public function testSelectArchiveFields( $contentHandlerUseDB, $expected ) {
709 $this->hideDeprecated( 'Revision::selectArchiveFields' );
710 $this->setMwGlobals( 'wgContentHandlerUseDB', $contentHandlerUseDB );
711 $this->assertEquals( $expected, Revision
::selectArchiveFields() );
715 * @covers Revision::selectTextFields
717 public function testSelectTextFields() {
718 $this->hideDeprecated( 'Revision::selectTextFields' );
724 Revision
::selectTextFields()
729 * @covers Revision::selectPageFields
731 public function testSelectPageFields() {
732 $this->hideDeprecated( 'Revision::selectPageFields' );
742 Revision
::selectPageFields()
747 * @covers Revision::selectUserFields
749 public function testSelectUserFields() {
750 $this->hideDeprecated( 'Revision::selectUserFields' );
755 Revision
::selectUserFields()
759 public function provideGetArchiveQueryInfo() {
760 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage OLD' => [
762 'wgContentHandlerUseDB' => false,
763 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
766 'tables' => [ 'archive' ],
781 'ar_comment_text' => 'ar_comment',
782 'ar_comment_data' => 'NULL',
783 'ar_comment_cid' => 'NULL',
788 yield
'wgContentHandlerUseDB true, wgCommentTableSchemaMigrationStage OLD' => [
790 'wgContentHandlerUseDB' => true,
791 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
794 'tables' => [ 'archive' ],
809 'ar_comment_text' => 'ar_comment',
810 'ar_comment_data' => 'NULL',
811 'ar_comment_cid' => 'NULL',
818 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage WRITE_BOTH' => [
820 'wgContentHandlerUseDB' => false,
821 'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH
,
826 'comment_ar_comment' => 'comment',
842 'ar_comment_text' => 'COALESCE( comment_ar_comment.comment_text, ar_comment )',
843 'ar_comment_data' => 'comment_ar_comment.comment_data',
844 'ar_comment_cid' => 'comment_ar_comment.comment_id',
847 'comment_ar_comment' => [
849 'comment_ar_comment.comment_id = ar_comment_id',
854 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage WRITE_NEW' => [
856 'wgContentHandlerUseDB' => false,
857 'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_NEW
,
862 'comment_ar_comment' => 'comment',
878 'ar_comment_text' => 'COALESCE( comment_ar_comment.comment_text, ar_comment )',
879 'ar_comment_data' => 'comment_ar_comment.comment_data',
880 'ar_comment_cid' => 'comment_ar_comment.comment_id',
883 'comment_ar_comment' => [
885 'comment_ar_comment.comment_id = ar_comment_id',
890 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage NEW' => [
892 'wgContentHandlerUseDB' => false,
893 'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW
,
898 'comment_ar_comment' => 'comment',
914 'ar_comment_text' => 'comment_ar_comment.comment_text',
915 'ar_comment_data' => 'comment_ar_comment.comment_data',
916 'ar_comment_cid' => 'comment_ar_comment.comment_id',
919 'comment_ar_comment' => [
921 'comment_ar_comment.comment_id = ar_comment_id',
929 * @covers Revision::getArchiveQueryInfo
930 * @dataProvider provideGetArchiveQueryInfo
932 public function testGetArchiveQueryInfo( $globals, $expected ) {
933 $this->setMwGlobals( $globals );
936 Revision
::getArchiveQueryInfo()
940 public function provideGetQueryInfo() {
941 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage OLD, opts none' => [
943 'wgContentHandlerUseDB' => false,
944 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
948 'tables' => [ 'revision' ],
961 'rev_comment_text' => 'rev_comment',
962 'rev_comment_data' => 'NULL',
963 'rev_comment_cid' => 'NULL',
968 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage OLD, opts page' => [
970 'wgContentHandlerUseDB' => false,
971 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
975 'tables' => [ 'revision', 'page' ],
988 'rev_comment_text' => 'rev_comment',
989 'rev_comment_data' => 'NULL',
990 'rev_comment_cid' => 'NULL',
1001 [ 'page_id = rev_page' ],
1006 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage OLD, opts user' => [
1008 'wgContentHandlerUseDB' => false,
1009 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
1013 'tables' => [ 'revision', 'user' ],
1026 'rev_comment_text' => 'rev_comment',
1027 'rev_comment_data' => 'NULL',
1028 'rev_comment_cid' => 'NULL',
1036 'user_id = rev_user',
1042 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage OLD, opts text' => [
1044 'wgContentHandlerUseDB' => false,
1045 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
1049 'tables' => [ 'revision', 'text' ],
1062 'rev_comment_text' => 'rev_comment',
1063 'rev_comment_data' => 'NULL',
1064 'rev_comment_cid' => 'NULL',
1071 [ 'rev_text_id=old_id' ],
1076 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage OLD, opts 3' => [
1078 'wgContentHandlerUseDB' => false,
1079 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
1081 [ 'text', 'page', 'user' ],
1083 'tables' => [ 'revision', 'page', 'user', 'text' ],
1096 'rev_comment_text' => 'rev_comment',
1097 'rev_comment_data' => 'NULL',
1098 'rev_comment_cid' => 'NULL',
1112 [ 'page_id = rev_page' ],
1118 'user_id = rev_user',
1123 [ 'rev_text_id=old_id' ],
1128 yield
'wgContentHandlerUseDB true, wgCommentTableSchemaMigrationStage OLD, opts none' => [
1130 'wgContentHandlerUseDB' => true,
1131 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD
,
1135 'tables' => [ 'revision' ],
1148 'rev_comment_text' => 'rev_comment',
1149 'rev_comment_data' => 'NULL',
1150 'rev_comment_cid' => 'NULL',
1151 'rev_content_format',
1152 'rev_content_model',
1157 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage WRITE_BOTH, opts none' => [
1159 'wgContentHandlerUseDB' => false,
1160 'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH
,
1166 'temp_rev_comment' => 'revision_comment_temp',
1167 'comment_rev_comment' => 'comment',
1181 'rev_comment_text' => 'COALESCE( comment_rev_comment.comment_text, rev_comment )',
1182 'rev_comment_data' => 'comment_rev_comment.comment_data',
1183 'rev_comment_cid' => 'comment_rev_comment.comment_id',
1186 'temp_rev_comment' => [
1188 'temp_rev_comment.revcomment_rev = rev_id',
1190 'comment_rev_comment' => [
1192 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id',
1197 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage WRITE_NEW, opts none' => [
1199 'wgContentHandlerUseDB' => false,
1200 'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_NEW
,
1206 'temp_rev_comment' => 'revision_comment_temp',
1207 'comment_rev_comment' => 'comment',
1221 'rev_comment_text' => 'COALESCE( comment_rev_comment.comment_text, rev_comment )',
1222 'rev_comment_data' => 'comment_rev_comment.comment_data',
1223 'rev_comment_cid' => 'comment_rev_comment.comment_id',
1226 'temp_rev_comment' => [
1228 'temp_rev_comment.revcomment_rev = rev_id',
1230 'comment_rev_comment' => [
1232 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id',
1237 yield
'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage NEW, opts none' => [
1239 'wgContentHandlerUseDB' => false,
1240 'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW
,
1246 'temp_rev_comment' => 'revision_comment_temp',
1247 'comment_rev_comment' => 'comment',
1261 'rev_comment_text' => 'comment_rev_comment.comment_text',
1262 'rev_comment_data' => 'comment_rev_comment.comment_data',
1263 'rev_comment_cid' => 'comment_rev_comment.comment_id',
1266 'temp_rev_comment' => [
1268 'temp_rev_comment.revcomment_rev = rev_id',
1270 'comment_rev_comment' => [
1272 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id',
1280 * @covers Revision::getQueryInfo
1281 * @dataProvider provideGetQueryInfo
1283 public function testGetQueryInfo( $globals, $options, $expected ) {
1284 $this->setMwGlobals( $globals );
1285 $this->assertEquals(
1287 Revision
::getQueryInfo( $options )