mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-28 08:50:07 +00:00
c76a5e84f9
I realized especially the method name html() was wrong. It does not return HTML. What it returns is still wikitext and must still be parsed. It only applies some early steps of the parsing process, e.g. expanding extension <tags>. Change-Id: I2c403a77eef843940f34f0933e4bfe58e6200ce5
63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Cite\Tests;
|
|
|
|
use Cite\CiteErrorReporter;
|
|
use Language;
|
|
use MediaWiki\MediaWikiServices;
|
|
use Parser;
|
|
|
|
/**
|
|
* @covers \Cite\CiteErrorReporter
|
|
*
|
|
* @license GPL-2.0-or-later
|
|
*/
|
|
class CiteErrorReporterTest extends \MediaWikiIntegrationTestCase {
|
|
|
|
/**
|
|
* @var Language
|
|
*/
|
|
private $language;
|
|
|
|
protected function setUp() : void {
|
|
parent::setUp();
|
|
|
|
$this->language = MediaWikiServices::getInstance()->getLanguageFactory()
|
|
->getLanguage( 'qqx' );
|
|
}
|
|
|
|
public function testHtmlError() {
|
|
$parser = $this->createMock( Parser::class );
|
|
$parser->expects( $this->once() )
|
|
->method( 'addTrackingCategory' );
|
|
$parser->expects( $this->once() )
|
|
->method( 'recursiveTagParse' )
|
|
->willReturnArgument( 0 );
|
|
|
|
$reporter = new CiteErrorReporter( $this->language, $parser );
|
|
$html = $reporter->halfParsed( 'cite_error_example', 'first param' );
|
|
$this->assertSame(
|
|
'<span class="error mw-ext-cite-error" lang="qqx" '
|
|
. 'dir="ltr">(cite_error: (cite_error_example: first param))</span>',
|
|
$html
|
|
);
|
|
}
|
|
|
|
public function testWikitextWarning() {
|
|
$parser = $this->createMock( Parser::class );
|
|
$parser->expects( $this->never() )
|
|
->method( 'addTrackingCategory' );
|
|
$parser->expects( $this->never() )
|
|
->method( 'recursiveTagParse' );
|
|
|
|
$reporter = new CiteErrorReporter( $this->language, $parser );
|
|
$wikitext = $reporter->plain( 'cite_warning_example', 'first param' );
|
|
$this->assertSame(
|
|
'<span class="warning mw-ext-cite-warning mw-ext-cite-warning-example" lang="qqx" '
|
|
. 'dir="ltr">(cite_warning: (cite_warning_example: first param))</span>',
|
|
$wikitext
|
|
);
|
|
}
|
|
|
|
}
|