2 namespace MediaWiki\Tests\Storage
;
4 use InvalidArgumentException
;
5 use MediaWiki\Storage\RevisionRecord
;
6 use MediaWiki\Storage\SlotRecord
;
11 * Tests RevisionStore against the intermediate MCR DB schema for use during schema migration.
13 * @covers \MediaWiki\Storage\RevisionStore
15 * @group RevisionStore
20 class McrWriteBothRevisionStoreDbTest
extends RevisionStoreDbTestBase
{
22 use McrWriteBothSchemaOverride
;
24 protected function revisionToRow( Revision
$rev, $options = [ 'page', 'user', 'comment' ] ) {
25 $row = parent
::revisionToRow( $rev, $options );
27 $row->rev_text_id
= (string)$rev->getTextId();
28 $row->rev_content_format
= (string)$rev->getContentFormat();
29 $row->rev_content_model
= (string)$rev->getContentModel();
34 protected function assertRevisionExistsInDatabase( RevisionRecord
$rev ) {
38 [ 'slot_revision_id' => $rev->getId() ],
45 [ 'content_address' => $rev->getSlot( 'main' )->getAddress() ],
49 parent
::assertRevisionExistsInDatabase( $rev );
53 * @param SlotRecord $a
54 * @param SlotRecord $b
56 protected function assertSameSlotContent( SlotRecord
$a, SlotRecord
$b ) {
57 parent
::assertSameSlotContent( $a, $b );
59 // Assert that the same content ID has been used
60 if ( $a->hasContentId() && $b->hasContentId() ) {
61 $this->assertSame( $a->getContentId(), $b->getContentId() );
65 public function provideGetArchiveQueryInfo() {
68 'tables' => [ 'archive' ],
69 'fields' => array_merge(
70 $this->getDefaultArchiveFields(),
72 'ar_comment_text' => 'ar_comment',
73 'ar_comment_data' => 'NULL',
74 'ar_comment_cid' => 'NULL',
75 'ar_user_text' => 'ar_user_text',
76 'ar_user' => 'ar_user',
87 public function provideGetQueryInfo() {
91 'tables' => [ 'revision' ],
92 'fields' => array_merge(
93 $this->getDefaultQueryFields(),
94 $this->getCommentQueryFields(),
95 $this->getActorQueryFields(),
96 $this->getContentHandlerQueryFields()
104 'tables' => [ 'revision', 'page', 'user' ],
105 'fields' => array_merge(
106 $this->getDefaultQueryFields(),
107 $this->getCommentQueryFields(),
108 $this->getActorQueryFields(),
109 $this->getContentHandlerQueryFields(),
121 'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
122 'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
128 public function provideGetSlotsQueryInfo() {
129 $db = wfGetDB( DB_REPLICA
);
135 'slots' => 'revision',
137 'fields' => array_merge(
139 'slot_revision_id' => 'slots.rev_id',
140 'slot_content_id' => 'NULL',
141 'slot_origin' => 'slots.rev_id',
142 'role_name' => $db->addQuotes( 'main' ),
152 'slots' => 'revision',
154 'fields' => array_merge(
156 'slot_revision_id' => 'slots.rev_id',
157 'slot_content_id' => 'NULL',
158 'slot_origin' => 'slots.rev_id',
159 'role_name' => $db->addQuotes( 'main' ),
160 'content_size' => 'slots.rev_len',
161 'content_sha1' => 'slots.rev_sha1',
163 'CONCAT(' . $db->addQuotes( 'tt:' ) . ',slots.rev_text_id)',
164 'model_name' => 'slots.rev_content_model',
172 public function provideInsertRevisionOn_failures() {
173 foreach ( parent
::provideInsertRevisionOn_failures() as $case ) {
177 yield
'slot that is not main slot' => [
180 'main' => new WikitextContent( 'Chicken' ),
181 'lalala' => new WikitextContent( 'Duck' ),
183 'comment' => $this->getRandomCommentStoreComment(),
184 'timestamp' => '20171117010101',
187 new InvalidArgumentException( 'Only the main slot is supported' )
191 public function provideNewMutableRevisionFromArray() {
192 foreach ( parent
::provideNewMutableRevisionFromArray() as $case ) {
196 yield
'Basic array, with page & id' => [
201 'timestamp' => '20171017114835',
202 'user_text' => '111.0.1.2',
204 'minor_edit' => false,
208 'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
209 'comment' => 'Goat Comment!',
210 'content_format' => 'text/x-wiki',
211 'content_model' => 'wikitext',