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 ) {
35 // New schema is being written
39 [ 'slot_revision_id' => $rev->getId() ],
46 [ 'content_address' => $rev->getSlot( 'main' )->getAddress() ],
50 // Legacy schema is still being written
52 [ 'revision', 'text' ],
54 [ 'rev_id' => $rev->getId(), 'rev_text_id > 0' ],
57 [ 'text' => [ 'INNER JOIN', [ 'rev_text_id = old_id' ] ] ]
60 parent
::assertRevisionExistsInDatabase( $rev );
64 * @param SlotRecord $a
65 * @param SlotRecord $b
67 protected function assertSameSlotContent( SlotRecord
$a, SlotRecord
$b ) {
68 parent
::assertSameSlotContent( $a, $b );
70 // Assert that the same content ID has been used
71 if ( $a->hasContentId() && $b->hasContentId() ) {
72 $this->assertSame( $a->getContentId(), $b->getContentId() );
76 public function provideInsertRevisionOn_failures() {
77 foreach ( parent
::provideInsertRevisionOn_failures() as $case ) {
81 yield
'slot that is not main slot' => [
84 'main' => new WikitextContent( 'Chicken' ),
85 'lalala' => new WikitextContent( 'Duck' ),
87 'comment' => $this->getRandomCommentStoreComment(),
88 'timestamp' => '20171117010101',
91 new InvalidArgumentException( 'Only the main slot is supported' )
95 public function provideNewMutableRevisionFromArray() {
96 foreach ( parent
::provideNewMutableRevisionFromArray() as $case ) {
100 yield
'Basic array, with page & id' => [
105 'timestamp' => '20171017114835',
106 'user_text' => '111.0.1.2',
108 'minor_edit' => false,
112 'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
113 'comment' => 'Goat Comment!',
114 'content_format' => 'text/x-wiki',
115 'content_model' => 'wikitext',