MediaWiki  1.33.0
PreMcrRevisionStoreDbTest.php
Go to the documentation of this file.
1 <?php
3 
4 use InvalidArgumentException;
8 
20 
22 
23  protected function revisionToRow( Revision $rev, $options = [ 'page', 'user', 'comment' ] ) {
24  $row = parent::revisionToRow( $rev, $options );
25 
26  $row->rev_text_id = (string)$rev->getTextId();
27  $row->rev_content_format = (string)$rev->getContentFormat();
28  $row->rev_content_model = (string)$rev->getContentModel();
29 
30  return $row;
31  }
32 
34  // Legacy schema is still being written
35  $this->assertSelect(
36  [ 'revision', 'text' ],
37  [ 'count(*)' ],
38  [ 'rev_id' => $rev->getId(), 'rev_text_id > 0' ],
39  [ [ 1 ] ],
40  [],
41  [ 'text' => [ 'JOIN', [ 'rev_text_id = old_id' ] ] ]
42  );
43 
44  parent::assertRevisionExistsInDatabase( $rev );
45  }
46 
48  foreach ( parent::provideInsertRevisionOn_failures() as $case ) {
49  yield $case;
50  }
51 
52  yield 'slot that is not main slot' => [
53  [
54  'content' => [
55  'main' => new WikitextContent( 'Chicken' ),
56  'lalala' => new WikitextContent( 'Duck' ),
57  ],
58  'comment' => $this->getRandomCommentStoreComment(),
59  'timestamp' => '20171117010101',
60  'user' => true,
61  ],
62  new InvalidArgumentException( 'Only the main slot is supported' )
63  ];
64  }
65 
67  foreach ( parent::provideNewMutableRevisionFromArray() as $case ) {
68  yield $case;
69  }
70 
71  yield 'Basic array, with page & id' => [
72  [
73  'id' => 2,
74  'page' => 1,
75  'text_id' => 2,
76  'timestamp' => '20171017114835',
77  'user_text' => '111.0.1.2',
78  'user' => 0,
79  'minor_edit' => false,
80  'deleted' => 0,
81  'len' => 46,
82  'parent_id' => 1,
83  'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
84  'comment' => 'Goat Comment!',
85  'content_format' => 'text/x-wiki',
86  'content_model' => 'wikitext',
87  ]
88  ];
89  }
90 
91 }
Revision\RevisionRecord
Page revision base class.
Definition: RevisionRecord.php:45
MediaWiki\Tests\Revision\PreMcrRevisionStoreDbTest\provideNewMutableRevisionFromArray
provideNewMutableRevisionFromArray()
Definition: PreMcrRevisionStoreDbTest.php:66
MediaWiki\Tests\Revision
Definition: FallbackSlotRoleHandlerTest.php:3
MediaWiki\Tests\Revision\PreMcrSchemaOverride
trait PreMcrSchemaOverride
Trait providing schema overrides that allow tests to run against the pre-MCR database schema.
Definition: PreMcrSchemaOverride.php:10
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Revision
Definition: Revision.php:40
MediaWiki\Tests\Revision\PreMcrRevisionStoreDbTest\provideInsertRevisionOn_failures
provideInsertRevisionOn_failures()
Definition: PreMcrRevisionStoreDbTest.php:47
MediaWiki\Tests\Revision\PreMcrRevisionStoreDbTest\revisionToRow
revisionToRow(Revision $rev, $options=[ 'page', 'user', 'comment'])
Definition: PreMcrRevisionStoreDbTest.php:23
MediaWiki\Tests\Revision\RevisionStoreDbTestBase
Database RevisionStore.
Definition: RevisionStoreDbTestBase.php:43
MediaWikiTestCase\assertSelect
assertSelect( $table, $fields, $condition, array $expectedRows, array $options=[], array $join_conds=[])
Asserts that the given database query yields the rows given by $expectedRows.
Definition: MediaWikiTestCase.php:2000
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
WikitextContent
Content object for wiki text pages.
Definition: WikitextContent.php:36
string
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Definition: hooks.txt:175
Revision\RevisionRecord\getId
getId()
Get revision ID.
Definition: RevisionRecord.php:273
MediaWiki\Tests\Revision\PreMcrRevisionStoreDbTest\assertRevisionExistsInDatabase
assertRevisionExistsInDatabase(RevisionRecord $rev)
Definition: PreMcrRevisionStoreDbTest.php:33
MediaWiki\Tests\Revision\RevisionStoreDbTestBase\getRandomCommentStoreComment
getRandomCommentStoreComment()
Definition: RevisionStoreDbTestBase.php:390
$options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:1985
$rev
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1769
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
MediaWiki\Tests\Revision\PreMcrRevisionStoreDbTest
Tests RevisionStore against the pre-MCR DB schema.
Definition: PreMcrRevisionStoreDbTest.php:19