X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FOutputPageTest.php;h=00a08a719d7a1a45db4f384ae45e3639b28abfc2;hb=4d596861e50fecd3fee8d545faf1610eb81487ef;hp=18d2a8a67147ab591f9027c934ee252a66e855df;hpb=c3089171b006962502a4c0ab156474dbe821b8a4;p=lhc%2Fweb%2Fwiklou.git
diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php
index 18d2a8a671..00a08a719d 100644
--- a/tests/phpunit/includes/OutputPageTest.php
+++ b/tests/phpunit/includes/OutputPageTest.php
@@ -1442,10 +1442,13 @@ class OutputPageTest extends MediaWikiTestCase {
$op = $this->newInstance();
$this->assertSame( '', $op->getHTML() );
+ $this->hideDeprecated( 'OutputPage::addWikiText' );
$this->hideDeprecated( 'OutputPage::addWikiTextTitle' );
$this->hideDeprecated( 'OutputPage::addWikiTextWithTitle' );
$this->hideDeprecated( 'OutputPage::addWikiTextTidy' );
$this->hideDeprecated( 'OutputPage::addWikiTextTitleTidy' );
+ $this->hideDeprecated( 'disabling tidy' );
+
if ( in_array(
$method,
[ 'addWikiTextWithTitle', 'addWikiTextTitleTidy', 'addWikiTextTitle' ]
@@ -1614,6 +1617,7 @@ class OutputPageTest extends MediaWikiTestCase {
* @covers OutputPage::addWikiText
*/
public function testAddWikiTextNoTitle() {
+ $this->hideDeprecated( 'OutputPage::addWikiText' );
$this->setExpectedException( MWException::class, 'Title is null' );
$op = $this->newInstance( [], null, 'notitle' );
@@ -1650,9 +1654,8 @@ class OutputPageTest extends MediaWikiTestCase {
$op = $this->newInstance();
$this->assertSame( '', $op->getHTML() );
$op->addWikiMsg( 'parentheses', "a" );
- // This is known to be bad unbalanced HTML; this will be fixed
- // by I743f4185a03403f8d9b9db010ff1ee4e9342e062 (T198214)
- $this->assertSame( "
(a)\n
", $op->getHTML() );
+ // The input is bad unbalanced HTML, but the output is tidied
+ $this->assertSame( "(a)\n
", $op->getHTML() );
}
/**
@@ -1803,6 +1806,7 @@ class OutputPageTest extends MediaWikiTestCase {
* @param string $expectedHTML Expected return value for parseInline(), if different
*/
public function testParse( array $args, $expectedHTML ) {
+ $this->hideDeprecated( 'OutputPage::parse' );
$op = $this->newInstance();
$this->assertSame( $expectedHTML, $op->parse( ...$args ) );
}
@@ -1817,34 +1821,51 @@ class OutputPageTest extends MediaWikiTestCase {
$this->assertTrue( true );
return;
}
+ $this->hideDeprecated( 'OutputPage::parseInline' );
$op = $this->newInstance();
$this->assertSame( $expectedHTMLInline ?? $expectedHTML, $op->parseInline( ...$args ) );
}
public function provideParse() {
return [
- 'List at start of line' => [
- [ '* List' ],
+ 'List at start of line (content)' => [
+ [ '* List', true, false ],
"",
+ "\n",
],
- 'List not at start' => [
- [ "* ''Not'' list", false ],
+ 'List at start of line (interface)' => [
+ [ '* List', true, true ],
+ "\n",
+ ],
+ 'List not at start (content)' => [
+ [ "* ''Not'' list", false, false ],
'* Not list
',
+ '* Not list',
+ ],
+ 'List not at start (interface)' => [
+ [ "* ''Not'' list", false, true ],
+ '* Not list',
],
- 'Interface' => [
+ 'Interface message' => [
[ "''Italic''", true, true ],
"Italic\n
",
'Italic',
],
- 'formatnum' => [
- [ '{{formatnum:123456.789}}' ],
+ 'formatnum (content)' => [
+ [ '{{formatnum:123456.789}}', true, false ],
"",
+ "123,456.789",
+ ],
+ 'formatnum (interface)' => [
+ [ '{{formatnum:123456.789}}', true, true ],
+ "123,456.789\n
",
+ "123,456.789",
],
- 'Language' => [
+ 'Language (content)' => [
[ '{{formatnum:123456.789}}', true, false, Language::factory( 'is' ) ],
"",
],
- 'Language with interface' => [
+ 'Language (interface)' => [
[ '{{formatnum:123456.789}}', true, true, Language::factory( 'is' ) ],
"123.456,789\n
",
'123.456,789',
@@ -1853,6 +1874,79 @@ class OutputPageTest extends MediaWikiTestCase {
[ '== Header ==' ],
'\n",
+ '' .
+ "\n",
+ ]
+ ];
+ }
+
+ /**
+ * @dataProvider provideParseAs
+ * @covers OutputPage::parseAsContent
+ * @param array $args To pass to parse()
+ * @param string $expectedHTML Expected return value for parseAsContent()
+ * @param string $expectedHTML Expected return value for parseInlineAsInterface(), if different
+ */
+ public function testParseAsContent(
+ array $args, $expectedHTML, $expectedHTMLInline = null
+ ) {
+ $op = $this->newInstance();
+ $this->assertSame( $expectedHTML, $op->parseAsContent( ...$args ) );
+ }
+
+ /**
+ * @dataProvider provideParseAs
+ * @covers OutputPage::parseAsInterface
+ * @param array $args To pass to parse()
+ * @param string $expectedHTML Expected return value for parseAsInterface()
+ * @param string $expectedHTML Expected return value for parseInlineAsInterface(), if different
+ */
+ public function testParseAsInterface(
+ array $args, $expectedHTML, $expectedHTMLInline = null
+ ) {
+ $op = $this->newInstance();
+ $this->assertSame( $expectedHTML, $op->parseAsInterface( ...$args ) );
+ }
+
+ /**
+ * @dataProvider provideParseAs
+ * @covers OutputPage::parseInlineAsInterface
+ */
+ public function testParseInlineAsInterface(
+ array $args, $expectedHTML, $expectedHTMLInline = null
+ ) {
+ $op = $this->newInstance();
+ $this->assertSame(
+ $expectedHTMLInline ?? $expectedHTML,
+ $op->parseInlineAsInterface( ...$args )
+ );
+ }
+
+ public function provideParseAs() {
+ return [
+ 'List at start of line' => [
+ [ '* List', true ],
+ "\n",
+ ],
+ 'List not at start' => [
+ [ "* ''Not'' list", false ],
+ '* Not list
',
+ '* Not list',
+ ],
+ 'Italics' => [
+ [ "''Italic''", true ],
+ "Italic\n
",
+ 'Italic',
+ ],
+ 'formatnum' => [
+ [ '{{formatnum:123456.789}}', true ],
+ "123,456.789\n
",
+ "123,456.789",
+ ],
+ 'No section edit links' => [
+ [ '== Header ==' ],
+ '' .
+ "\n",
]
];
}
@@ -1861,20 +1955,49 @@ class OutputPageTest extends MediaWikiTestCase {
* @covers OutputPage::parse
*/
public function testParseNullTitle() {
- $this->setExpectedException( MWException::class, 'Empty $mTitle in OutputPage::parse' );
+ $this->hideDeprecated( 'OutputPage::parse' );
+ $this->setExpectedException( MWException::class, 'Empty $mTitle in OutputPage::parseInternal' );
$op = $this->newInstance( [], null, 'notitle' );
$op->parse( '' );
}
/**
- * @covers OutputPage::parse
+ * @covers OutputPage::parseInline
*/
public function testParseInlineNullTitle() {
- $this->setExpectedException( MWException::class, 'Empty $mTitle in OutputPage::parse' );
+ $this->hideDeprecated( 'OutputPage::parseInline' );
+ $this->setExpectedException( MWException::class, 'Empty $mTitle in OutputPage::parseInternal' );
$op = $this->newInstance( [], null, 'notitle' );
$op->parseInline( '' );
}
+ /**
+ * @covers OutputPage::parseAsContent
+ */
+ public function testParseAsContentNullTitle() {
+ $this->setExpectedException( MWException::class, 'Empty $mTitle in OutputPage::parseInternal' );
+ $op = $this->newInstance( [], null, 'notitle' );
+ $op->parseAsContent( '' );
+ }
+
+ /**
+ * @covers OutputPage::parseAsInterface
+ */
+ public function testParseAsInterfaceNullTitle() {
+ $this->setExpectedException( MWException::class, 'Empty $mTitle in OutputPage::parseInternal' );
+ $op = $this->newInstance( [], null, 'notitle' );
+ $op->parseAsInterface( '' );
+ }
+
+ /**
+ * @covers OutputPage::parseInlineAsInterface
+ */
+ public function testParseInlineAsInterfaceNullTitle() {
+ $this->setExpectedException( MWException::class, 'Empty $mTitle in OutputPage::parseInternal' );
+ $op = $this->newInstance( [], null, 'notitle' );
+ $op->parseInlineAsInterface( '' );
+ }
+
/**
* @covers OutputPage::setCdnMaxage
* @covers OutputPage::lowerCdnMaxage