From: addshore Date: Sat, 18 Nov 2017 18:08:45 +0000 (+0000) Subject: [MCR] tests for Revision::getArchiveQueryInfo X-Git-Tag: 1.31.0-rc.0~1467 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=211143d7eb51a4ceb6c8f81ffd7287b0b25ffff7;p=lhc%2Fweb%2Fwiklou.git [MCR] tests for Revision::getArchiveQueryInfo Bug: T180210 Change-Id: Icb016be8d69dfdfa83f44bbc4fb259b5beb30678 --- diff --git a/tests/phpunit/includes/RevisionTest.php b/tests/phpunit/includes/RevisionTest.php index a4f55d0ab1..f860a7dbc8 100644 --- a/tests/phpunit/includes/RevisionTest.php +++ b/tests/phpunit/includes/RevisionTest.php @@ -756,4 +756,185 @@ class RevisionTest extends MediaWikiTestCase { ); } + public function provideGetArchiveQueryInfo() { + yield 'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage OLD' => [ + [ + 'wgContentHandlerUseDB' => false, + 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD, + ], + [ + 'tables' => [ 'archive' ], + 'fields' => [ + 'ar_id', + 'ar_page_id', + 'ar_rev_id', + 'ar_text', + 'ar_text_id', + 'ar_timestamp', + 'ar_user_text', + 'ar_user', + 'ar_minor_edit', + 'ar_deleted', + 'ar_len', + 'ar_parent_id', + 'ar_sha1', + 'ar_comment_text' => 'ar_comment', + 'ar_comment_data' => 'NULL', + 'ar_comment_cid' => 'NULL', + ], + 'joins' => [], + ] + ]; + yield 'wgContentHandlerUseDB true, wgCommentTableSchemaMigrationStage OLD' => [ + [ + 'wgContentHandlerUseDB' => true, + 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD, + ], + [ + 'tables' => [ 'archive' ], + 'fields' => [ + 'ar_id', + 'ar_page_id', + 'ar_rev_id', + 'ar_text', + 'ar_text_id', + 'ar_timestamp', + 'ar_user_text', + 'ar_user', + 'ar_minor_edit', + 'ar_deleted', + 'ar_len', + 'ar_parent_id', + 'ar_sha1', + 'ar_comment_text' => 'ar_comment', + 'ar_comment_data' => 'NULL', + 'ar_comment_cid' => 'NULL', + 'ar_content_format', + 'ar_content_model', + ], + 'joins' => [], + ] + ]; + yield 'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage WRITE_BOTH' => [ + [ + 'wgContentHandlerUseDB' => false, + 'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH, + ], + [ + 'tables' => [ + 'archive', + 'comment_ar_comment' => 'comment', + ], + 'fields' => [ + 'ar_id', + 'ar_page_id', + 'ar_rev_id', + 'ar_text', + 'ar_text_id', + 'ar_timestamp', + 'ar_user_text', + 'ar_user', + 'ar_minor_edit', + 'ar_deleted', + 'ar_len', + 'ar_parent_id', + 'ar_sha1', + 'ar_comment_text' => 'COALESCE( comment_ar_comment.comment_text, ar_comment )', + 'ar_comment_data' => 'comment_ar_comment.comment_data', + 'ar_comment_cid' => 'comment_ar_comment.comment_id', + ], + 'joins' => [ + 'comment_ar_comment' => [ + 'LEFT JOIN', + 'comment_ar_comment.comment_id = ar_comment_id', + ], + ], + ] + ]; + yield 'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage WRITE_NEW' => [ + [ + 'wgContentHandlerUseDB' => false, + 'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_NEW, + ], + [ + 'tables' => [ + 'archive', + 'comment_ar_comment' => 'comment', + ], + 'fields' => [ + 'ar_id', + 'ar_page_id', + 'ar_rev_id', + 'ar_text', + 'ar_text_id', + 'ar_timestamp', + 'ar_user_text', + 'ar_user', + 'ar_minor_edit', + 'ar_deleted', + 'ar_len', + 'ar_parent_id', + 'ar_sha1', + 'ar_comment_text' => 'COALESCE( comment_ar_comment.comment_text, ar_comment )', + 'ar_comment_data' => 'comment_ar_comment.comment_data', + 'ar_comment_cid' => 'comment_ar_comment.comment_id', + ], + 'joins' => [ + 'comment_ar_comment' => [ + 'LEFT JOIN', + 'comment_ar_comment.comment_id = ar_comment_id', + ], + ], + ] + ]; + yield 'wgContentHandlerUseDB false, wgCommentTableSchemaMigrationStage NEW' => [ + [ + 'wgContentHandlerUseDB' => false, + 'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW, + ], + [ + 'tables' => [ + 'archive', + 'comment_ar_comment' => 'comment', + ], + 'fields' => [ + 'ar_id', + 'ar_page_id', + 'ar_rev_id', + 'ar_text', + 'ar_text_id', + 'ar_timestamp', + 'ar_user_text', + 'ar_user', + 'ar_minor_edit', + 'ar_deleted', + 'ar_len', + 'ar_parent_id', + 'ar_sha1', + 'ar_comment_text' => 'comment_ar_comment.comment_text', + 'ar_comment_data' => 'comment_ar_comment.comment_data', + 'ar_comment_cid' => 'comment_ar_comment.comment_id', + ], + 'joins' => [ + 'comment_ar_comment' => [ + 'JOIN', + 'comment_ar_comment.comment_id = ar_comment_id', + ], + ], + ] + ]; + } + + /** + * @covers Revision::getArchiveQueryInfo + * @dataProvider provideGetArchiveQueryInfo + */ + public function testGetArchiveQueryInfo( $globals, $expected ) { + $this->setMwGlobals( $globals ); + $this->assertEquals( + $expected, + Revision::getArchiveQueryInfo() + ); + } + }