use Content;
use Language;
use LogicException;
+use MediaWiki\Revision\MutableRevisionRecord;
+use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\RevisionRenderer;
-use MediaWiki\Storage\MutableRevisionRecord;
-use MediaWiki\Storage\RevisionRecord;
-use MediaWiki\Storage\SlotRecord;
-use MediaWiki\User\UserIdentityValue;
+use MediaWiki\Revision\SlotRecord;
use MediaWikiTestCase;
+use MediaWiki\User\UserIdentityValue;
use ParserOptions;
use ParserOutput;
use PHPUnit\Framework\MockObject\MockObject;
$this->assertSame( $html, $rr->getSlotParserOutput( SlotRecord::MAIN )->getText() );
}
+ public function testGetRenderedRevision_known() {
+ $renderer = $this->newRevisionRenderer( 100, true ); // use master
+ $title = $this->getMockTitle( 7, 21 );
+
+ $rev = new MutableRevisionRecord( $title );
+ $rev->setId( 21 ); // current!
+ $rev->setUser( new UserIdentityValue( 9, 'Frank', 0 ) );
+ $rev->setTimestamp( '20180101000003' );
+ $rev->setComment( CommentStoreComment::newUnsavedComment( '' ) );
+
+ $text = "uncached text";
+ $rev->setContent( SlotRecord::MAIN, new WikitextContent( $text ) );
+
+ $output = new ParserOutput( 'cached text' );
+
+ $options = ParserOptions::newCanonical( 'canonical' );
+ $rr = $renderer->getRenderedRevision(
+ $rev,
+ $options,
+ null,
+ [ 'known-revision-output' => $output ]
+ );
+
+ $this->assertSame( $output, $rr->getRevisionParserOutput() );
+ $this->assertSame( 'cached text', $rr->getRevisionParserOutput()->getText() );
+ $this->assertSame( 'cached text', $rr->getSlotParserOutput( SlotRecord::MAIN )->getText() );
+ }
+
public function testGetRenderedRevision_old() {
$renderer = $this->newRevisionRenderer( 100 );
$title = $this->getMockTitle( 7, 21 );