X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles_versions%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fparser%2FParserOutputTest.php;h=efcc4e079e4ea55b2a11c1bde77ac95163a9788b;hb=74426f3cf796b149f1ae445e41815bbe148640b2;hp=e660e0964320ab1988fc6803a9b0ff7bba586ff6;hpb=4f21e6be661f7305abc223bb31600970a3fb5326;p=lhc%2Fweb%2Fwiklou.git
diff --git a/tests/phpunit/includes/parser/ParserOutputTest.php b/tests/phpunit/includes/parser/ParserOutputTest.php
index e660e09643..efcc4e079e 100644
--- a/tests/phpunit/includes/parser/ParserOutputTest.php
+++ b/tests/phpunit/includes/parser/ParserOutputTest.php
@@ -1,5 +1,7 @@
assertArrayNotHasKey( 'foo', $properties );
}
+ /**
+ * @covers ParserOutput::getText
+ * @dataProvider provideGetText
+ * @param array $options Options to getText()
+ * @param array $poState ParserOptions state fields to set
+ * @param string $text Parser text
+ * @param string $expect Expected output
+ */
+ public function testGetText( $options, $poState, $text, $expect ) {
+ $this->setMwGlobals( [
+ 'wgArticlePath' => '/wiki/$1',
+ 'wgScriptPath' => '/w',
+ 'wgScript' => '/w/index.php',
+ ] );
+ $this->hideDeprecated( 'ParserOutput stateful allowTOC' );
+ $this->hideDeprecated( 'ParserOutput stateful enableSectionEditLinks' );
+
+ $po = new ParserOutput( $text );
+
+ // Emulate Parser
+ $po->setEditSectionTokens( true );
+
+ if ( $poState ) {
+ $wrap = TestingAccessWrapper::newFromObject( $po );
+ foreach ( $poState as $key => $value ) {
+ $wrap->$key = $value;
+ }
+ }
+
+ $actual = $po->getText( $options );
+ $this->assertSame( $expect, $actual );
+ }
+
+ public static function provideGetText() {
+ // phpcs:disable Generic.Files.LineLength
+ $text = << Test document.
+ One
+ Two
+ Two point one
+ Three
+ Test document.
+ One
+ Two
+ Two point one
+ Three
+ Test document.
+ One
+ Two
+ Two point one
+ Three
+ Test document.
+ One
+ Two
+ Two point one
+ Three
+ Test document.
+ One
+ Two
+ Two point one
+ Three
+ Test document.
+ One
+ Two
+ Two point one
+ Three
+ Test document.
+ One
+ Two
+ Two point one
+ Three
+Contents
+
+Section 1
+Section 2
+Section 2.1
+Section 3
+Contents
+
+Section 1[edit]
+Section 2[edit]
+Section 2.1[edit]
+Section 3[edit]
+Section 1[edit]
+Section 2[edit]
+Section 2.1[edit]
+Section 3[edit]
+Contents
+
+Section 1
+Section 2
+Section 2.1
+Section 3
+Contents
+
+Section 1[edit]
+Section 2[edit]
+Section 2.1[edit]
+Section 3[edit]
+Contents
+
+Section 1
+Section 2
+Section 2.1
+Section 3
+Section 1[edit]
+Section 2[edit]
+Section 2.1[edit]
+Section 3[edit]
+
One +
+Two +
+Two point one +
+Three +
+EOF + ], + 'Unwrap without a mw-parser-output wrapper' => [ + [ 'unwrap' => true ], [], ' ', ' ' + ], + ]; + // phpcs:enable + } + }