3 namespace MediaWiki\Tests\Revision
;
5 use InvalidArgumentException
;
6 use MediaWiki\Revision\RevisionRecord
;
11 * Tests RevisionStore against the pre-MCR DB schema.
13 * @covers \MediaWiki\Revision\RevisionStore
15 * @group RevisionStore
20 class PreMcrRevisionStoreDbTest
extends RevisionStoreDbTestBase
{
22 use PreMcrSchemaOverride
;
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 // Legacy schema is still being written
37 [ 'revision', 'text' ],
39 [ 'rev_id' => $rev->getId(), 'rev_text_id > 0' ],
42 [ 'text' => [ 'JOIN', [ 'rev_text_id = old_id' ] ] ]
45 parent
::assertRevisionExistsInDatabase( $rev );
48 public function provideInsertRevisionOn_failures() {
49 foreach ( parent
::provideInsertRevisionOn_failures() as $case ) {
53 yield
'slot that is not main slot' => [
56 'main' => new WikitextContent( 'Chicken' ),
57 'lalala' => new WikitextContent( 'Duck' ),
59 'comment' => $this->getRandomCommentStoreComment(),
60 'timestamp' => '20171117010101',
63 new InvalidArgumentException( 'Only the main slot is supported' )
67 public function provideNewMutableRevisionFromArray() {
68 foreach ( parent
::provideNewMutableRevisionFromArray() as $case ) {
72 yield
'Basic array, with page & id' => [
77 'timestamp' => '20171017114835',
78 'user_text' => '111.0.1.2',
80 'minor_edit' => false,
84 'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
85 'comment' => 'Goat Comment!',
86 'content_format' => 'text/x-wiki',
87 'content_model' => 'wikitext',