X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fparser%2FParserOutputTest.php;h=441d60df7bea4ac85d6488904fb53b3eaf093681;hb=e74ba29aa6b86995a79200fc8b1bb2932d3a1675;hp=fe46f2cc632337786989323618aff8959b360eaa;hpb=dfcf9ffd67883186d22ad6b03331ba567a42d352;p=lhc%2Fweb%2Fwiklou.git
diff --git a/tests/phpunit/includes/parser/ParserOutputTest.php b/tests/phpunit/includes/parser/ParserOutputTest.php
index fe46f2cc63..441d60df7b 100644
--- a/tests/phpunit/includes/parser/ParserOutputTest.php
+++ b/tests/phpunit/includes/parser/ParserOutputTest.php
@@ -1,5 +1,7 @@
assertFalse( $po->hasCustomDataUpdates() );
+ public function testGetText( $options, $poState, $text, $expect ) {
+ $this->setMwGlobals( [
+ 'wgArticlePath' => '/wiki/$1',
+ 'wgScriptPath' => '/w',
+ 'wgScript' => '/w/index.php',
+ ] );
- $dataUpdate = $this->getMock( 'DataUpdate' );
- $po->addSecondaryDataUpdate( $dataUpdate );
- $this->assertTrue( $po->hasCustomDataUpdates() );
- }
+ $po = new ParserOutput( $text );
- /**
- * @covers ParserOutput::getSecondaryDataUpdates
- * @covers ParserOutput::addSecondaryDataUpdate
- */
- public function testGetSecondaryDataUpdates() {
- // NOTE: getSecondaryDataUpdates always returns a LinksUpdate object
- // in addition to the DataUpdates registered via addSecondaryDataUpdate().
+ // Emulate Parser
+ $po->setEditSectionTokens( true );
- $title = Title::makeTitle( NS_MAIN, 'Dummy' );
- $title->resetArticleID( 7777777 );
+ if ( $poState ) {
+ $wrap = TestingAccessWrapper::newFromObject( $po );
+ foreach ( $poState as $key => $value ) {
+ $wrap->$key = $value;
+ }
+ }
- $po = new ParserOutput();
- $this->assertCount( 1, $po->getSecondaryDataUpdates( $title ) );
+ $actual = $po->getText( $options );
+ $this->assertSame( $expect, $actual );
+ }
- $dataUpdate = $this->getMock( 'DataUpdate' );
- $po->addSecondaryDataUpdate( $dataUpdate );
- $this->assertCount( 2, $po->getSecondaryDataUpdates( $title ) );
+ public static function provideGetText() {
+ // @codingStandardsIgnoreStart Generic.Files.LineLength
+ $text = <<
One +
+Two +
+Two point one +
+Three +
+EOF; - // Test Fallback to getTitleText - $this->insertPage( 'Project:ParserOutputTestDummyPage' ); - $po->setTitleText( 'Project:ParserOutputTestDummyPage' ); - $this->assertCount( 2, $po->getSecondaryDataUpdates() ); - } + return [ + 'No stateless options, default state' => [ + [], [], $text, <<One +
+Two +
+Two point one +
+Three +
+EOF + ], + 'No stateless options, TOC statefully disabled' => [ + [], [ 'mTOCEnabled' => false ], $text, <<One +
+Two +
+Two point one +
+Three +
+EOF + ], + 'No stateless options, section edits statefully disabled' => [ + [], [ 'mEditSectionTokens' => false ], $text, <<One +
+Two +
+Two point one +
+Three +
+EOF + ], + 'Stateless options override stateful settings' => [ + [ 'allowTOC' => true, 'enableSectionEditLinks' => true ], + [ 'mTOCEnabled' => false, 'mEditSectionTokens' => false ], + $text, <<One +
+Two +
+Two point one +
+Three +
+EOF + ], + 'Statelessly disable section edit links' => [ + [ 'enableSectionEditLinks' => false ], [], $text, <<One +
+Two +
+Two point one +
+Three +
+EOF + ], + 'Statelessly disable TOC' => [ + [ 'allowTOC' => false ], [], $text, <<One +
+Two +
+Two point one +
+Three +
+EOF + ], + ]; + // @codingStandardsIgnoreEnd } }