mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-18 19:12:16 +00:00
b68832ace0
We were calling Title::newFromText() before setupEnv(), which meant that the title for each test case was parsed using the default rules for English, rather than the rules for the specified wiki. This only makes a practical difference for tests with self-links. Changed the only such test to demonstrate the fix. Change-Id: I45561f1c9f0d149e2b743f0000b742bf6fc014af
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 = self::getHtml( $dom );
|
|
$expectedPath = $expected;
|
|
$expected = self::getText( $expected );
|
|
$config = self::getJson( $config );
|
|
$data = self::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, 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' );
|
|
}
|
|
|
|
}
|