diff options
author | C. Scott Ananian <cscott@cscott.net> | 2024-01-12 00:07:33 -0500 |
---|---|---|
committer | C. Scott Ananian <cscott@cscott.net> | 2024-02-07 21:22:06 -0500 |
commit | 242c6d2cf9d20122754d3a5819d9c14489cc4ecd (patch) | |
tree | b68d9f6cd353344f4787a535ed2625abcb81aa2b /tests/phpunit/includes/parser/ParserOutputTest.php | |
parent | 5c0e9216e4a9f1eb691cc75e1b9b204d2a517fa3 (diff) | |
download | mediawikicore-242c6d2cf9d20122754d3a5819d9c14489cc4ecd.tar.gz mediawikicore-242c6d2cf9d20122754d3a5819d9c14489cc4ecd.zip |
Introduce ParserOutput:setFromParserOptions() and use for preview flag
Bug: T341010
Co-Authored-by: cananian <cananian@wikimedia.org>
Co-Authored-by: ihurbain <ihurbainpalatin@wikimedia.org>
Change-Id: I03125fdaa7dd71ba57d593e85ecb98be6806f3f6
Diffstat (limited to 'tests/phpunit/includes/parser/ParserOutputTest.php')
-rw-r--r-- | tests/phpunit/includes/parser/ParserOutputTest.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/phpunit/includes/parser/ParserOutputTest.php b/tests/phpunit/includes/parser/ParserOutputTest.php index 6349c1727222..1c74e66a8947 100644 --- a/tests/phpunit/includes/parser/ParserOutputTest.php +++ b/tests/phpunit/includes/parser/ParserOutputTest.php @@ -2,6 +2,7 @@ use MediaWiki\MainConfigNames; use MediaWiki\Parser\ParserOutput; +use MediaWiki\Parser\ParserOutputFlags; use MediaWiki\Parser\ParserOutputStringSets; use MediaWiki\Tests\Parser\ParserCacheSerializationTestCases; use MediaWiki\Title\Title; @@ -1401,4 +1402,21 @@ EOF $po->setExtensionData( 'parsoid-render-id', "1234/LegacyRenderId" ); $this->assertEquals( "LegacyRenderId", $po->getRenderId() ); } + + public function testSetFromParserOptions() { + $pOptions = ParserOptions::newFromAnon(); + $pOutput = new ParserOutput; + $pOutput->setFromParserOptions( $pOptions ); + $this->assertSame( 'mw-parser-output', $pOutput->getWrapperDivClass() ); + $this->assertFalse( $pOutput->getOutputFlag( ParserOutputFlags::IS_PREVIEW ) ); + $this->assertTrue( $pOutput->isCacheable() ); + + $pOptions->setWrapOutputClass( 'test-wrapper' ); + $pOptions->setIsPreview( true ); + $pOutput = new ParserOutput; + $pOutput->setFromParserOptions( $pOptions ); + $this->assertEquals( 'test-wrapper', $pOutput->getWrapperDivClass() ); + $this->assertTrue( $pOutput->getOutputFlag( ParserOutputFlags::IS_PREVIEW ) ); + $this->assertFalse( $pOutput->isCacheable() ); + } } |