2 namespace MediaWiki\Tests\Storage
;
4 use CommentStoreComment
;
5 use MediaWiki\MediaWikiServices
;
6 use MediaWiki\Storage\RevisionRecord
;
7 use MediaWiki\Storage\SlotRecord
;
13 * Tests RevisionStore against the post-migration MCR DB schema.
15 * @covers \MediaWiki\Storage\RevisionStore
17 * @group RevisionStore
22 class McrRevisionStoreDbTest
extends RevisionStoreDbTestBase
{
24 use McrSchemaOverride
;
26 protected function assertRevisionExistsInDatabase( RevisionRecord
$rev ) {
27 $numberOfSlots = count( $rev->getSlotRoles() );
29 // new schema is written
33 [ 'slot_revision_id' => $rev->getId() ],
34 [ [ (string)$numberOfSlots ] ]
37 $store = MediaWikiServices
::getInstance()->getRevisionStore();
38 $revQuery = $store->getSlotsQueryInfo( [ 'content' ] );
44 'slot_revision_id' => $rev->getId(),
46 [ [ (string)$numberOfSlots ] ],
51 parent
::assertRevisionExistsInDatabase( $rev );
55 * @param SlotRecord $a
56 * @param SlotRecord $b
58 protected function assertSameSlotContent( SlotRecord
$a, SlotRecord
$b ) {
59 parent
::assertSameSlotContent( $a, $b );
61 // Assert that the same content ID has been used
62 $this->assertSame( $a->getContentId(), $b->getContentId() );
65 public function provideInsertRevisionOn_successes() {
66 foreach ( parent
::provideInsertRevisionOn_successes() as $case ) {
70 yield
'Multi-slot revision insertion' => [
73 'main' => new WikitextContent( 'Chicken' ),
74 'aux' => new TextContent( 'Egg' ),
77 'comment' => $this->getRandomCommentStoreComment(),
78 'timestamp' => '20171117010101',
84 public function provideNewNullRevision() {
85 foreach ( parent
::provideNewNullRevision() as $case ) {
90 Title
::newFromText( 'UTPage_notAutoCreated' ),
93 'main' => new WikitextContent( 'Chicken' ),
94 'aux' => new WikitextContent( 'Omelet' ),
97 CommentStoreComment
::newUnsavedComment( __METHOD__
. ' comment multi' ),
101 public function provideNewMutableRevisionFromArray() {
102 foreach ( parent
::provideNewMutableRevisionFromArray() as $case ) {
106 yield
'Basic array, multiple roles' => [
110 'timestamp' => '20171017114835',
111 'user_text' => '111.0.1.2',
113 'minor_edit' => false,
117 'sha1' => '89qs83keq9c9ccw9olvvm4oc9oq50ii',
118 'comment' => 'Goat Comment!',
120 'main' => new WikitextContent( 'Söme Cöntent' ),
121 'aux' => new TextContent( 'Öther Cöntent' ),
127 public function testGetQueryInfo_NoSlotDataJoin() {
128 $store = MediaWikiServices
::getInstance()->getRevisionStore();
129 $queryInfo = $store->getQueryInfo();
131 // with the new schema enabled, query info should not join the main slot info
132 $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['tables'] ) );
133 $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['joins'] ) );
136 public function provideGetArchiveQueryInfo() {
142 'fields' => array_merge(
143 $this->getDefaultArchiveFields( false ),
145 'ar_comment_text' => 'ar_comment',
146 'ar_comment_data' => 'NULL',
147 'ar_comment_cid' => 'NULL',
148 'ar_user_text' => 'ar_user_text',
149 'ar_user' => 'ar_user',
150 'ar_actor' => 'NULL',
159 public function provideGetQueryInfo() {
160 // TODO: more option variations
169 'fields' => array_merge(
170 $this->getDefaultQueryFields( false ),
171 $this->getCommentQueryFields(),
172 $this->getActorQueryFields(),
184 'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
185 'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
191 public function provideGetSlotsQueryInfo() {
199 'fields' => array_merge(
208 'slot_roles' => [ 'INNER JOIN', [ 'slot_role_id = role_id' ] ],
221 'fields' => array_merge(
234 'slot_roles' => [ 'INNER JOIN', [ 'slot_role_id = role_id' ] ],
235 'content' => [ 'INNER JOIN', [ 'slot_content_id = content_id' ] ],
236 'content_models' => [ 'INNER JOIN', [ 'content_model = model_id' ] ],