2 namespace MediaWiki\Tests\Storage
;
4 use InvalidArgumentException
;
5 use MediaWiki\Storage\RevisionRecord
;
10 * Tests RevisionStore against the pre-MCR DB schema.
12 * @covers \MediaWiki\Storage\RevisionStore
14 * @group RevisionStore
19 class PreMcrRevisionStoreDbTest
extends RevisionStoreDbTestBase
{
21 use PreMcrSchemaOverride
;
23 protected function revisionToRow( Revision
$rev, $options = [ 'page', 'user', 'comment' ] ) {
24 $row = parent
::revisionToRow( $rev, $options );
26 $row->rev_text_id
= (string)$rev->getTextId();
27 $row->rev_content_format
= (string)$rev->getContentFormat();
28 $row->rev_content_model
= (string)$rev->getContentModel();
33 protected function assertRevisionExistsInDatabase( RevisionRecord
$rev ) {
34 // Legacy schema is still being written
36 [ 'revision', 'text' ],
38 [ 'rev_id' => $rev->getId(), 'rev_text_id > 0' ],
41 [ 'text' => [ 'INNER JOIN', [ 'rev_text_id = old_id' ] ] ]
44 parent
::assertRevisionExistsInDatabase( $rev );
47 public function provideGetArchiveQueryInfo() {
50 'tables' => [ 'archive' ],
51 'fields' => array_merge(
52 $this->getDefaultArchiveFields(),
54 'ar_comment_text' => 'ar_comment',
55 'ar_comment_data' => 'NULL',
56 'ar_comment_cid' => 'NULL',
57 'ar_user_text' => 'ar_user_text',
58 'ar_user' => 'ar_user',
69 public function provideGetQueryInfo() {
73 'tables' => [ 'revision' ],
74 'fields' => array_merge(
75 $this->getDefaultQueryFields(),
76 $this->getCommentQueryFields(),
77 $this->getActorQueryFields(),
78 $this->getContentHandlerQueryFields()
84 [ 'page', 'user', 'text' ],
86 'tables' => [ 'revision', 'page', 'user', 'text' ],
87 'fields' => array_merge(
88 $this->getDefaultQueryFields(),
89 $this->getCommentQueryFields(),
90 $this->getActorQueryFields(),
91 $this->getContentHandlerQueryFields(),
105 'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
106 'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
107 'text' => [ 'INNER JOIN', [ 'rev_text_id=old_id' ] ],
113 public function provideGetSlotsQueryInfo() {
114 $db = wfGetDB( DB_REPLICA
);
120 'slots' => 'revision',
122 'fields' => array_merge(
124 'slot_revision_id' => 'slots.rev_id',
125 'slot_content_id' => 'NULL',
126 'slot_origin' => 'slots.rev_id',
127 'role_name' => $db->addQuotes( 'main' ),
137 'slots' => 'revision',
139 'fields' => array_merge(
141 'slot_revision_id' => 'slots.rev_id',
142 'slot_content_id' => 'NULL',
143 'slot_origin' => 'slots.rev_id',
144 'role_name' => $db->addQuotes( 'main' ),
145 'content_size' => 'slots.rev_len',
146 'content_sha1' => 'slots.rev_sha1',
148 'CONCAT(' . $db->addQuotes( 'tt:' ) . ',slots.rev_text_id)',
149 'model_name' => 'slots.rev_content_model',
157 public function provideInsertRevisionOn_failures() {
158 foreach ( parent
::provideInsertRevisionOn_failures() as $case ) {
162 yield
'slot that is not main slot' => [
165 'main' => new WikitextContent( 'Chicken' ),
166 'lalala' => new WikitextContent( 'Duck' ),
168 'comment' => $this->getRandomCommentStoreComment(),
169 'timestamp' => '20171117010101',
172 new InvalidArgumentException( 'Only the main slot is supported' )
176 public function provideNewMutableRevisionFromArray() {
177 foreach ( parent
::provideNewMutableRevisionFromArray() as $case ) {
181 yield
'Basic array, with page & id' => [
186 'timestamp' => '20171017114835',
187 'user_text' => '111.0.1.2',
189 'minor_edit' => false,
193 'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
194 'comment' => 'Goat Comment!',
195 'content_format' => 'text/x-wiki',
196 'content_model' => 'wikitext',