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 intermediate MCR DB schema for use during schema migration.
15 * @covers \MediaWiki\Storage\RevisionStore
17 * @group RevisionStore
22 class McrReadNewRevisionStoreDbTest
extends RevisionStoreDbTestBase
{
24 use McrReadNewSchemaOverride
;
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 // Legacy schema is still being written
53 [ 'revision', 'text' ],
55 [ 'rev_id' => $rev->getId(), 'rev_text_id > 0' ],
58 [ 'text' => [ 'INNER JOIN', [ 'rev_text_id = old_id' ] ] ]
61 parent
::assertRevisionExistsInDatabase( $rev );
65 * @param SlotRecord $a
66 * @param SlotRecord $b
68 protected function assertSameSlotContent( SlotRecord
$a, SlotRecord
$b ) {
69 parent
::assertSameSlotContent( $a, $b );
71 // Assert that the same content ID has been used
72 $this->assertSame( $a->getContentId(), $b->getContentId() );
75 public function provideInsertRevisionOn_successes() {
76 foreach ( parent
::provideInsertRevisionOn_successes() as $case ) {
80 yield
'Multi-slot revision insertion' => [
83 'main' => new WikitextContent( 'Chicken' ),
84 'aux' => new TextContent( 'Egg' ),
87 'comment' => $this->getRandomCommentStoreComment(),
88 'timestamp' => '20171117010101',
94 public function provideNewNullRevision() {
95 foreach ( parent
::provideNewNullRevision() as $case ) {
100 Title
::newFromText( 'UTPage_notAutoCreated' ),
103 'main' => new WikitextContent( 'Chicken' ),
104 'aux' => new WikitextContent( 'Omelet' ),
107 CommentStoreComment
::newUnsavedComment( __METHOD__
. ' comment multi' ),
111 public function testGetQueryInfo_NoSlotDataJoin() {
112 $store = MediaWikiServices
::getInstance()->getRevisionStore();
113 $queryInfo = $store->getQueryInfo();
115 // with the new schema enabled, query info should not join the main slot info
116 $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['tables'] ) );
117 $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['joins'] ) );
120 public function provideNewMutableRevisionFromArray() {
121 foreach ( parent
::provideNewMutableRevisionFromArray() as $case ) {
125 yield
'Basic array, multiple roles' => [
129 'timestamp' => '20171017114835',
130 'user_text' => '111.0.1.2',
132 'minor_edit' => false,
136 'sha1' => '89qs83keq9c9ccw9olvvm4oc9oq50ii',
137 'comment' => 'Goat Comment!',
139 'main' => new WikitextContent( 'Söme Cöntent' ),
140 'aux' => new TextContent( 'Öther Cöntent' ),