mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-19 11:32:16 +00:00
af54bae2ec
While in many cases the class will never be sub-classed, it's easier just to always use static:: and not worry about predicting which classes might have problems in the future. Change-Id: I23072a1701b5acf62bb3379a877de97627d8fcf3
59 lines
1.7 KiB
PHP
59 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Tests;
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
use Title;
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
/**
|
|
* @coversDefaultClass \MediaWiki\Extension\DiscussionTools\CommentFormatter
|
|
*/
|
|
class CommentFormatterTest extends IntegrationTestCase {
|
|
|
|
/**
|
|
* @dataProvider provideAddDiscussionToolsInternal
|
|
* @covers ::addDiscussionToolsInternal
|
|
*/
|
|
public function testAddDiscussionToolsInternal(
|
|
string $name, string $title, string $dom, string $expected, string $config, string $data
|
|
): void {
|
|
$dom = static::getHtml( $dom );
|
|
$expectedPath = $expected;
|
|
$expected = static::getText( $expected );
|
|
$config = static::getJson( $config );
|
|
$data = static::getJson( $data );
|
|
|
|
$this->setupEnv( $config, $data );
|
|
$title = Title::newFromText( $title );
|
|
MockCommentFormatter::$parser = TestUtils::createParser( $data );
|
|
|
|
$commentFormatter = TestingAccessWrapper::newFromClass( MockCommentFormatter::class );
|
|
|
|
$actual = $commentFormatter->addDiscussionToolsInternal( $dom, $title );
|
|
|
|
$mockSubStore = new MockSubscriptionStore();
|
|
$qqxLang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'qqx' );
|
|
|
|
$actual = MockCommentFormatter::postprocessTopicSubscription(
|
|
$actual, $qqxLang, $mockSubStore, static::getTestUser()->getUser()
|
|
);
|
|
|
|
$actual = MockCommentFormatter::postprocessReplyTool(
|
|
$actual, $qqxLang
|
|
);
|
|
|
|
// Optionally write updated content to the "reply HTML" files
|
|
if ( getenv( 'DISCUSSIONTOOLS_OVERWRITE_TESTS' ) ) {
|
|
static::overwriteTextFile( $expectedPath, $actual );
|
|
}
|
|
|
|
static::assertEquals( $expected, $actual, $name );
|
|
}
|
|
|
|
public function provideAddDiscussionToolsInternal(): array {
|
|
return static::getJson( '../cases/formattedreply.json' );
|
|
}
|
|
|
|
}
|