2 namespace MediaWiki\Tests\Storage
;
4 use InvalidArgumentException
;
5 use MediaWiki\MediaWikiServices
;
6 use MediaWiki\Storage\RevisionRecord
;
7 use MediaWiki\Storage\SlotRecord
;
12 * Tests RevisionStore against the intermediate MCR DB schema for use during schema migration.
14 * @covers \MediaWiki\Storage\RevisionStore
16 * @group RevisionStore
21 class McrReadNewRevisionStoreDbTest
extends RevisionStoreDbTestBase
{
23 use McrReadNewSchemaOverride
;
25 protected function assertRevisionExistsInDatabase( RevisionRecord
$rev ) {
29 [ 'slot_revision_id' => $rev->getId() ],
36 [ 'content_address' => $rev->getSlot( 'main' )->getAddress() ],
40 parent
::assertRevisionExistsInDatabase( $rev );
44 * @param SlotRecord $a
45 * @param SlotRecord $b
47 protected function assertSameSlotContent( SlotRecord
$a, SlotRecord
$b ) {
48 parent
::assertSameSlotContent( $a, $b );
50 // Assert that the same content ID has been used
51 $this->assertSame( $a->getContentId(), $b->getContentId() );
54 public function testGetQueryInfo_NoSlotDataJoin() {
55 $store = MediaWikiServices
::getInstance()->getRevisionStore();
56 $queryInfo = $store->getQueryInfo();
58 // with the new schema enabled, query info should not join the main slot info
59 $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['tables'] ) );
60 $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['joins'] ) );
63 public function provideGetArchiveQueryInfo() {
69 'fields' => array_merge(
70 $this->getDefaultArchiveFields( false ),
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',
86 public function provideGetQueryInfo() {
87 // TODO: more option variations
96 'fields' => array_merge(
97 $this->getDefaultQueryFields( false ),
98 $this->getCommentQueryFields(),
99 $this->getActorQueryFields(),
111 'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
112 'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
118 public function provideGetSlotsQueryInfo() {
126 'fields' => array_merge(
135 'slot_roles' => [ 'INNER JOIN', [ 'slot_role_id = role_id' ] ],
148 'fields' => array_merge(
161 'slot_roles' => [ 'INNER JOIN', [ 'slot_role_id = role_id' ] ],
162 'content' => [ 'INNER JOIN', [ 'slot_content_id = content_id' ] ],
163 'content_models' => [ 'INNER JOIN', [ 'content_model = model_id' ] ],
169 public function provideInsertRevisionOn_failures() {
170 foreach ( parent
::provideInsertRevisionOn_failures() as $case ) {
174 yield
'slot that is not main slot' => [
177 'main' => new WikitextContent( 'Chicken' ),
178 'lalala' => new WikitextContent( 'Duck' ),
180 'comment' => $this->getRandomCommentStoreComment(),
181 'timestamp' => '20171117010101',
184 new InvalidArgumentException( 'Only the main slot is supported' )
188 public function provideNewMutableRevisionFromArray() {
189 foreach ( parent
::provideNewMutableRevisionFromArray() as $case ) {
193 yield
'Basic array, multiple roles' => [
197 'timestamp' => '20171017114835',
198 'user_text' => '111.0.1.2',
200 'minor_edit' => false,
204 'sha1' => '89qs83keq9c9ccw9olvvm4oc9oq50ii',
205 'comment' => 'Goat Comment!',
207 'main' => new WikitextContent( 'Söme Cöntent' ),
208 'aux' => new TextContent( 'Öther Cöntent' ),