mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-29 02:25:44 +00:00
32cd64ec6a
As CommentFormatter no longer needs HTMLFormatter, remove the inheritance and make addReplyLinks a static method. Testing locally this is marginally slower, going from 2.55s to 2.9s for the CommentFormatterTest case. Bug: T266317 Bug: T267973 Change-Id: If69749cae678a1647a138d782a32032189f55cec
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Tests;
|
|
|
|
use MediaWiki\Extension\DiscussionTools\CommentFormatter;
|
|
|
|
/**
|
|
* @coversDefaultClass \MediaWiki\Extension\DiscussionTools\CommentFormatter
|
|
*/
|
|
class CommentFormatterTest extends CommentTestCase {
|
|
|
|
/**
|
|
* @dataProvider provideAddReplyLinks
|
|
* @covers ::addReplyLinks
|
|
*/
|
|
public function testAddReplyLinks(
|
|
string $name, string $dom, string $expected, string $config, string $data
|
|
) : void {
|
|
$origPath = $dom;
|
|
$dom = self::getHtml( $dom );
|
|
$expectedPath = $expected;
|
|
$expected = self::getHtml( $expected );
|
|
$config = self::getJson( $config );
|
|
$data = self::getJson( $data );
|
|
|
|
$this->setupEnv( $config, $data );
|
|
|
|
$doc = self::createDocument( CommentFormatter::addReplyLinks( $dom ) );
|
|
$expectedDoc = self::createDocument( $expected );
|
|
|
|
// Optionally write updated content to the "reply HTML" files
|
|
if ( getenv( 'DISCUSSIONTOOLS_OVERWRITE_TESTS' ) ) {
|
|
self::overwriteHtmlFile( $expectedPath, $doc, $origPath );
|
|
}
|
|
|
|
// saveHtml is not dirty-diff safe, but for testing it is probably faster than DOMCompat::getOuterHTML
|
|
self::assertEquals( $expectedDoc->saveHtml(), $doc->saveHtml(), $name );
|
|
}
|
|
|
|
public function provideAddReplyLinks() : array {
|
|
return self::getJson( '../cases/formattedreply.json' );
|
|
}
|
|
|
|
}
|