mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-16 20:58:28 +00:00
284115a184
I haven't really reviewed the outputs, but at least a) they don't crash b) they will fail if the output suddenly changes (which could cause problems due to caching). Bug: T252555 Change-Id: I1bbcbc5dd17ce1e24b3622062f5e8df4baf5f389
48 lines
1.3 KiB
PHP
48 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 );
|
|
|
|
$formatter = new CommentFormatter( $dom );
|
|
$formatter->addReplyLinks();
|
|
|
|
$doc = self::createDocument( $formatter->getText() );
|
|
$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' );
|
|
}
|
|
|
|
}
|