);
}
+ protected function addCoreDBData() {
+ // Blank out. This would fail with a modified schema, and we don't need it.
+ }
+
+ /**
+ * @return int
+ */
+ abstract protected function getMcrMigrationStage();
+
+ /**
+ * @return string[]
+ */
+ abstract protected function getMcrTablesToReset();
+
protected function setUp() {
global $wgContLang;
+ $this->tablesUsed += $this->getMcrTablesToReset();
+
parent::setUp();
$this->mergeMwGlobalArrayValue(
);
$this->setMwGlobals( 'wgContentHandlerUseDB', $this->getContentHandlerUseDB() );
+ $this->setMwGlobals(
+ 'wgMultiContentRevisionSchemaMigrationStage',
+ $this->getMcrMigrationStage()
+ );
MWNamespace::clearCaches();
// Reset namespace cache
$wgContLang->resetNamespaces();
+ $this->overrideMwServices();
+
if ( !$this->testPage ) {
/**
* We have to create a new page for each subclass as the page creation may result
[
'rev_id',
'rev_page',
- 'rev_text_id',
'rev_minor_edit',
'rev_deleted',
'rev_len',
[ [
strval( $rev->getId() ),
strval( $this->testPage->getId() ),
- strval( $textId ),
'0',
'0',
'13',
);
}
+ public function provideInsertOn_exceptionOnIncomplete() {
+ $content = new TextContent( '' );
+ $user = User::newFromName( 'Foo' );
+
+ yield 'no parent' => [
+ [
+ 'content' => $content,
+ 'comment' => 'test',
+ 'user' => $user,
+ ],
+ IncompleteRevisionException::class,
+ "rev_page field must not be 0!"
+ ];
+
+ yield 'no comment' => [
+ [
+ 'content' => $content,
+ 'page' => 7,
+ 'user' => $user,
+ ],
+ IncompleteRevisionException::class,
+ "comment must not be NULL!"
+ ];
+
+ yield 'no content' => [
+ [
+ 'comment' => 'test',
+ 'page' => 7,
+ 'user' => $user,
+ ],
+ IncompleteRevisionException::class,
+ "Uninitialized field: content_address" // XXX: message may change
+ ];
+ }
+
/**
+ * @dataProvider provideInsertOn_exceptionOnIncomplete
* @covers Revision::insertOn
*/
- public function testInsertOn_exceptionOnNoPage() {
+ public function testInsertOn_exceptionOnIncomplete( $array, $expException, $expMessage ) {
// If an ExternalStore is set don't use it.
$this->setMwGlobals( 'wgDefaultExternalStore', false );
- $this->setExpectedException(
- IncompleteRevisionException::class,
- "rev_page field must not be 0!"
- );
+ $this->setExpectedException( $expException, $expMessage );
$title = Title::newFromText( 'Nonexistant-' . __METHOD__ );
- $rev = new Revision( [], 0, $title );
+ $rev = new Revision( $array, 0, $title );
$rev->insertOn( wfGetDB( DB_MASTER ) );
}
return $f + [ 'ar_namespace', 'ar_title' ];
},
];
- yield [
- function ( $f ) {
- unset( $f['ar_text'] );
- return $f;
- },
- ];
yield [
function ( $f ) {
unset( $f['ar_text_id'] );
$services->getService( '_SqlBlobStore' ),
$services->getMainWANObjectCache(),
$services->getCommentStore(),
+ $services->getContentModelStore(),
+ $services->getSlotRoleStore(),
+ $this->getMcrMigrationStage(),
$services->getActorMigration()
);
$rev = new Revision( [
'page' => $this->testPage->getId(),
'content_model' => $this->testPage->getContentModel(),
- 'text_id' => 123456789, // not in the test DB
+ 'id' => 123456789, // not in the test DB
] );
Wikimedia\suppressWarnings(); // bad text_id will trigger a warning.
*/
public function testNewKnownCurrent() {
// Setup the services
+ $this->resetGlobalServices();
$cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
$this->setService( 'MainWANObjectCache', $cache );
$db = wfGetDB( DB_MASTER );
$rev = $this->testPage->getRevision();
// Clear any previous cache for the revision during creation
- $key = $cache->makeGlobalKey( 'revision-row-1.29',
+ $key = $cache->makeGlobalKey( RevisionStore::ROW_CACHE_KEY,
$db->getDomainID(),
$rev->getPage(),
$rev->getId()