mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 00:13:36 +00:00
Load site config data in CommentFormatter tests
This fixes missing reply links in arwiki test output. Change-Id: I24d3b8371a8343c4445c716fadf0692be0924eed
This commit is contained in:
parent
452c6401d7
commit
8b71a2b5dc
|
@ -9,6 +9,18 @@ use Wikimedia\Parsoid\Utils\DOMUtils;
|
|||
|
||||
class CommentFormatter {
|
||||
|
||||
/**
|
||||
* Get a comment parser object for a DOM element
|
||||
*
|
||||
* This method exists so it can mocked in tests.
|
||||
*
|
||||
* @param DOMElement $container
|
||||
* @return CommentParser
|
||||
*/
|
||||
protected static function getParser( DOMElement $container ) : CommentParser {
|
||||
return CommentParser::newFromGlobalState( $container );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add reply links to some HTML
|
||||
*
|
||||
|
@ -29,7 +41,7 @@ class CommentFormatter {
|
|||
return $html;
|
||||
}
|
||||
|
||||
$parser = CommentParser::newFromGlobalState( $container );
|
||||
$parser = static::getParser( $container );
|
||||
$threadItems = $parser->getThreadItems();
|
||||
|
||||
foreach ( $threadItems as $threadItem ) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace MediaWiki\Extension\DiscussionTools\Tests;
|
||||
|
||||
use MediaWiki\Extension\DiscussionTools\CommentFormatter;
|
||||
use RequestContext;
|
||||
|
||||
/**
|
||||
|
@ -25,8 +24,9 @@ class CommentFormatterTest extends CommentTestCase {
|
|||
$data = self::getJson( $data );
|
||||
|
||||
$this->setupEnv( $config, $data );
|
||||
MockCommentFormatter::$data = $data;
|
||||
|
||||
$actual = CommentFormatter::addReplyLinks( $dom, RequestContext::getMain()->getLanguage() );
|
||||
$actual = MockCommentFormatter::addReplyLinks( $dom, RequestContext::getMain()->getLanguage() );
|
||||
|
||||
$doc = self::createDocument( $actual );
|
||||
$expectedDoc = self::createDocument( $expected );
|
||||
|
|
|
@ -105,7 +105,7 @@ abstract class CommentTestCase extends MediaWikiTestCase {
|
|||
* @param array $data
|
||||
* @return CommentParser
|
||||
*/
|
||||
protected static function createParser( DOMElement $rootNode, array $data ) : CommentParser {
|
||||
public static function createParser( DOMElement $rootNode, array $data ) : CommentParser {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
return new CommentParser(
|
||||
$rootNode,
|
||||
|
|
21
tests/phpunit/MockCommentFormatter.php
Normal file
21
tests/phpunit/MockCommentFormatter.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\DiscussionTools\Tests;
|
||||
|
||||
use DOMElement;
|
||||
use MediaWiki\Extension\DiscussionTools\CommentFormatter;
|
||||
use MediaWiki\Extension\DiscussionTools\CommentParser;
|
||||
|
||||
class MockCommentFormatter extends CommentFormatter {
|
||||
|
||||
public static $data;
|
||||
|
||||
/**
|
||||
* @param DOMElement $container
|
||||
* @return CommentParser
|
||||
*/
|
||||
protected static function getParser( DOMElement $container ) : CommentParser {
|
||||
return CommentTestCase::createParser( $container, static::$data );
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue