3 namespace MediaWiki\Tests\Revision
;
5 use CommentStoreComment
;
6 use MediaWiki\MediaWikiServices
;
7 use MediaWiki\Revision\RevisionRecord
;
8 use MediaWiki\Revision\SlotRecord
;
14 * Tests RevisionStore against the intermediate MCR DB schema for use during schema migration.
16 * @covers \MediaWiki\Revision\RevisionStore
18 * @group RevisionStore
23 class McrReadNewRevisionStoreDbTest
extends RevisionStoreDbTestBase
{
25 use McrReadNewSchemaOverride
;
27 protected function assertRevisionExistsInDatabase( RevisionRecord
$rev ) {
28 $numberOfSlots = count( $rev->getSlotRoles() );
30 // new schema is written
34 [ 'slot_revision_id' => $rev->getId() ],
35 [ [ (string)$numberOfSlots ] ]
38 $store = MediaWikiServices
::getInstance()->getRevisionStore();
39 $revQuery = $store->getSlotsQueryInfo( [ 'content' ] );
45 'slot_revision_id' => $rev->getId(),
47 [ [ (string)$numberOfSlots ] ],
52 // Legacy schema is still being written
54 [ 'revision', 'text' ],
56 [ 'rev_id' => $rev->getId(), 'rev_text_id > 0' ],
59 [ 'text' => [ 'JOIN', [ 'rev_text_id = old_id' ] ] ]
62 parent
::assertRevisionExistsInDatabase( $rev );
66 * @param SlotRecord $a
67 * @param SlotRecord $b
69 protected function assertSameSlotContent( SlotRecord
$a, SlotRecord
$b ) {
70 parent
::assertSameSlotContent( $a, $b );
72 // Assert that the same content ID has been used
73 $this->assertSame( $a->getContentId(), $b->getContentId() );
76 public function provideInsertRevisionOn_successes() {
77 foreach ( parent
::provideInsertRevisionOn_successes() as $case ) {
81 yield
'Multi-slot revision insertion' => [
84 'main' => new WikitextContent( 'Chicken' ),
85 'aux' => new TextContent( 'Egg' ),
88 'comment' => $this->getRandomCommentStoreComment(),
89 'timestamp' => '20171117010101',
95 public function provideNewNullRevision() {
96 foreach ( parent
::provideNewNullRevision() as $case ) {
101 Title
::newFromText( 'UTPage_notAutoCreated' ),
104 'main' => new WikitextContent( 'Chicken' ),
105 'aux' => new WikitextContent( 'Omelet' ),
108 CommentStoreComment
::newUnsavedComment( __METHOD__
. ' comment multi' ),
112 public function testGetQueryInfo_NoSlotDataJoin() {
113 $store = MediaWikiServices
::getInstance()->getRevisionStore();
114 $queryInfo = $store->getQueryInfo();
116 // with the new schema enabled, query info should not join the main slot info
117 $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['tables'] ) );
118 $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['joins'] ) );
121 public function provideNewMutableRevisionFromArray() {
122 foreach ( parent
::provideNewMutableRevisionFromArray() as $case ) {
126 yield
'Basic array, multiple roles' => [
130 'timestamp' => '20171017114835',
131 'user_text' => '111.0.1.2',
133 'minor_edit' => false,
137 'sha1' => '89qs83keq9c9ccw9olvvm4oc9oq50ii',
138 'comment' => 'Goat Comment!',
140 'main' => new WikitextContent( 'Söme Cöntent' ),
141 'aux' => new TextContent( 'Öther Cöntent' ),