/**
* Get the error message as HTML. This is done by parsing the wikitext error
* message.
- *
- * @note: this does not perform a full wikitext to HTML conversion, it merely applies
- * a message transformation.
- * @todo figure out whether that is actually The Right Thing.
+ * @param string $shortContext a short enclosing context message name, to
+ * be used when there is a single error
+ * @param string $longContext a long enclosing context message name, for a list
+ * @return String
*/
public function getHTML( $shortContext = false, $longContext = false ) {
$text = $this->getWikiText( $shortContext, $longContext );
- return MessageCache::singleton()->transform( $text, true );
+ $out = MessageCache::singleton()->parse( $text, null, true, true );
+ return $out instanceof ParserOutput ? $out->getText() : $out;
}
/**
* this can not really be done now due to use of wfMessage()->plain()
* It is possible to mock such methods but only if namespaces are used
*/
- public function testGetWikiText( Status $status, $expected ) {
- $this->assertEquals( $expected, $status->getWikiText() );
+ public function testGetWikiText( Status $status, $wikitext, $html ) {
+ $this->assertEquals( $wikitext, $status->getWikiText() );
}
/**
* this can not really be done now due to use of $this->getWikiText using wfMessage()->plain()
* It is possible to mock such methods but only if namespaces are used
*/
- public function testGetHtml( Status $status, $expected ) {
- $this->assertEquals( $expected, $status->getHTML() );
+ public function testGetHtml( Status $status, $wikitext, $html) {
+ $this->assertEquals( $html, $status->getHTML() );
}
/**
$testCases[ 'GoodStatus' ] = array(
new Status(),
"Internal error: Status::getWikiText called for a good result, this is incorrect\n",
+ "<p>Internal error: Status::getWikiText called for a good result, this is incorrect\n</p>",
);
$status = new Status();
$testCases[ 'GoodButNoError' ] = array(
$status,
"Internal error: Status::getWikiText: Invalid result object: no error text but not OK\n",
+ "<p>Internal error: Status::getWikiText: Invalid result object: no error text but not OK\n</p>",
);
$status = new Status();
$testCases[ '1StringWarning' ] = array(
$status,
"<fooBar!>",
+ "<p><fooBar!>\n</p>",
);
$status = new Status();
$testCases[ '2StringWarnings' ] = array(
$status,
"* <fooBar!>\n* <fooBar2!>\n",
+ "<ul>\n<li> <fooBar!>\n</li>\n<li> <fooBar2!>\n</li>\n</ul>\n",
);
$status = new Status();
$testCases[ '1MessageWarning' ] = array(
$status,
"<fooBar!>",
+ "<p><fooBar!>\n</p>",
);
$status = new Status();
$testCases[ '2MessageWarnings' ] = array(
$status,
"* <fooBar!>\n* <fooBar2!>\n",
+ "<ul>\n<li> <fooBar!>\n</li>\n<li> <fooBar2!>\n</li>\n</ul>\n",
);
return $testCases;