X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FRevision%2FMcrRevisionStoreDbTest.php;h=c0ff44b0b883646535fde40ae490ab064b40e41d;hb=5a451fd01be397db3209c1881a335423706da5c2;hp=0aa220c5da9ae571e6dd5da897380528f286525f;hpb=61544d6eb235342d004a2fefc159167f28c69099;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/Revision/McrRevisionStoreDbTest.php b/tests/phpunit/includes/Revision/McrRevisionStoreDbTest.php index 0aa220c5da..c0ff44b0b8 100644 --- a/tests/phpunit/includes/Revision/McrRevisionStoreDbTest.php +++ b/tests/phpunit/includes/Revision/McrRevisionStoreDbTest.php @@ -187,4 +187,56 @@ class McrRevisionStoreDbTest extends RevisionStoreDbTestBase { $this->assertRevisionRecordsEqual( $return, $loaded ); } + /** + * Conditions to use together with getSlotsQueryInfo() when selecting slot rows for a given + * revision. + * + * @return array + */ + protected function getSlotRevisionConditions( $revId ) { + return [ 'slot_revision_id' => $revId ]; + } + + /** + * @covers \MediaWiki\Revision\RevisionStore::newRevisionsFromBatch + * @throws \MWException + */ + public function testNewRevisionsFromBatch_error() { + $page = $this->getTestPage(); + $text = __METHOD__ . 'b-ä'; + /** @var Revision $rev1 */ + $rev1 = $page->doEditContent( + new WikitextContent( $text . '1' ), + __METHOD__ . 'b', + 0, + false, + $this->getTestUser()->getUser() + )->value['revision']; + $invalidRow = $this->revisionToRow( $rev1 ); + $invalidRow->rev_id = 100500; + $result = MediaWikiServices::getInstance()->getRevisionStore() + ->newRevisionsFromBatch( + [ $this->revisionToRow( $rev1 ), $invalidRow ], + [ + 'slots' => [ SlotRecord::MAIN ], + 'content' => true + ] + ); + $this->assertFalse( $result->isGood() ); + $this->assertNotEmpty( $result->getErrors() ); + $records = $result->getValue(); + $this->assertRevisionRecordMatchesRevision( $rev1, $records[$rev1->getId()] ); + $this->assertSame( $text . '1', + $records[$rev1->getId()]->getContent( SlotRecord::MAIN )->serialize() ); + $this->assertEquals( $page->getTitle()->getDBkey(), + $records[$rev1->getId()]->getPageAsLinkTarget()->getDBkey() ); + $this->assertNull( $records[$invalidRow->rev_id] ); + $this->assertSame( [ [ + 'type' => 'warning', + 'message' => 'internalerror', + 'params' => [ + "Couldn't find slots for rev 100500" + ] + ] ], $result->getErrors() ); + } }