2 namespace MediaWiki\Tests\Storage
;
4 use InvalidArgumentException
;
9 * Tests RevisionStore against the pre-MCR DB schema.
11 * @covers \MediaWiki\Storage\RevisionStore
13 * @group RevisionStore
18 class PreMcrRevisionStoreDbTest
extends RevisionStoreDbTestBase
{
20 use PreMcrSchemaOverride
;
22 protected function revisionToRow( Revision
$rev, $options = [ 'page', 'user', 'comment' ] ) {
23 $row = parent
::revisionToRow( $rev, $options );
25 $row->rev_text_id
= (string)$rev->getTextId();
26 $row->rev_content_format
= (string)$rev->getContentFormat();
27 $row->rev_content_model
= (string)$rev->getContentModel();
32 public function provideGetArchiveQueryInfo() {
35 'tables' => [ 'archive' ],
36 'fields' => array_merge(
37 $this->getDefaultArchiveFields(),
39 'ar_comment_text' => 'ar_comment',
40 'ar_comment_data' => 'NULL',
41 'ar_comment_cid' => 'NULL',
42 'ar_user_text' => 'ar_user_text',
43 'ar_user' => 'ar_user',
54 public function provideGetQueryInfo() {
58 'tables' => [ 'revision' ],
59 'fields' => array_merge(
60 $this->getDefaultQueryFields(),
61 $this->getCommentQueryFields(),
62 $this->getActorQueryFields(),
63 $this->getContentHandlerQueryFields()
69 [ 'page', 'user', 'text' ],
71 'tables' => [ 'revision', 'page', 'user', 'text' ],
72 'fields' => array_merge(
73 $this->getDefaultQueryFields(),
74 $this->getCommentQueryFields(),
75 $this->getActorQueryFields(),
76 $this->getContentHandlerQueryFields(),
90 'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
91 'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
92 'text' => [ 'INNER JOIN', [ 'rev_text_id=old_id' ] ],
98 public function provideGetSlotsQueryInfo() {
99 $db = wfGetDB( DB_REPLICA
);
105 'slots' => 'revision',
107 'fields' => array_merge(
109 'slot_revision_id' => 'slots.rev_id',
110 'slot_content_id' => 'NULL',
111 'slot_origin' => 'slots.rev_id',
112 'role_name' => $db->addQuotes( 'main' ),
122 'slots' => 'revision',
124 'fields' => array_merge(
126 'slot_revision_id' => 'slots.rev_id',
127 'slot_content_id' => 'NULL',
128 'slot_origin' => 'slots.rev_id',
129 'role_name' => $db->addQuotes( 'main' ),
130 'content_size' => 'slots.rev_len',
131 'content_sha1' => 'slots.rev_sha1',
133 'CONCAT(' . $db->addQuotes( 'tt:' ) . ',slots.rev_text_id)',
134 'model_name' => 'slots.rev_content_model',
142 public function provideInsertRevisionOn_failures() {
143 foreach ( parent
::provideInsertRevisionOn_failures() as $case ) {
147 yield
'slot that is not main slot' => [
150 'main' => new WikitextContent( 'Chicken' ),
151 'lalala' => new WikitextContent( 'Duck' ),
153 'comment' => $this->getRandomCommentStoreComment(),
154 'timestamp' => '20171117010101',
157 new InvalidArgumentException( 'Only the main slot is supported' )
161 public function provideNewMutableRevisionFromArray() {
162 foreach ( parent
::provideNewMutableRevisionFromArray() as $case ) {
166 yield
'Basic array, with page & id' => [
171 'timestamp' => '20171017114835',
172 'user_text' => '111.0.1.2',
174 'minor_edit' => false,
178 'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
179 'comment' => 'Goat Comment!',
180 'content_format' => 'text/x-wiki',
181 'content_model' => 'wikitext',