mediawiki-extensions-Discus.../tests/phpunit/CommentFormatterTest.php
Ed Sanders 722a4e5198 Avoid splitting ParserCache on user language
Bug: T280295
Change-Id: I87eab83803d24c11db4d723377bf7b40390b2e70
2021-04-21 11:57:30 +00:00

55 lines
1.6 KiB
PHP

<?php
namespace MediaWiki\Extension\DiscussionTools\Tests;
use RequestContext;
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, RequestContext::getMain()->getLanguage() );
$mockSubStore = new MockSubscriptionStore();
$actual = MockCommentFormatter::postprocessTopicSubscription(
$actual, RequestContext::getMain()->getLanguage(), $mockSubStore, self::getTestUser()->getUser()
);
$actual = MockCommentFormatter::postprocessReplyTool(
$actual, RequestContext::getMain()->getLanguage()
);
// 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' );
}
}