mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-17 05:10:50 +00:00
9c8d709b8a
Otherwise they will fail whenever translations are updated (and they are failing right now). Change-Id: I849c57b86d36fb6c7739cc31a74df741e08462f4
57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Tests;
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
/**
|
|
* @coversDefaultClass \MediaWiki\Extension\DiscussionTools\CommentFormatter
|
|
*/
|
|
class CommentFormatterTest extends IntegrationTestCase {
|
|
|
|
/**
|
|
* @dataProvider provideAddDiscussionToolsInternal
|
|
* @covers ::addDiscussionToolsInternal
|
|
*/
|
|
public function testAddDiscussionToolsInternal(
|
|
string $name, string $dom, string $expected, string $config, string $data
|
|
) : void {
|
|
$dom = self::getHtml( $dom );
|
|
$expectedPath = $expected;
|
|
$expected = self::getText( $expected );
|
|
$config = self::getJson( $config );
|
|
$data = self::getJson( $data );
|
|
|
|
$this->setupEnv( $config, $data );
|
|
MockCommentFormatter::$data = $data;
|
|
|
|
$commentFormatter = TestingAccessWrapper::newFromClass( MockCommentFormatter::class );
|
|
|
|
$actual = $commentFormatter->addDiscussionToolsInternal( $dom );
|
|
|
|
$mockSubStore = new MockSubscriptionStore();
|
|
$qqxLang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'qqx' );
|
|
|
|
$actual = MockCommentFormatter::postprocessTopicSubscription(
|
|
$actual, $qqxLang, $mockSubStore, self::getTestUser()->getUser()
|
|
);
|
|
|
|
$actual = MockCommentFormatter::postprocessReplyTool(
|
|
$actual, $qqxLang
|
|
);
|
|
|
|
// Optionally write updated content to the "reply HTML" files
|
|
if ( getenv( 'DISCUSSIONTOOLS_OVERWRITE_TESTS' ) ) {
|
|
self::overwriteTextFile( $expectedPath, $actual );
|
|
}
|
|
|
|
self::assertEquals( $expected, $actual, $name );
|
|
}
|
|
|
|
public function provideAddDiscussionToolsInternal() : array {
|
|
return self::getJson( '../cases/formattedreply.json' );
|
|
}
|
|
|
|
}
|