mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-11 08:08:37 +00:00
af54bae2ec
While in many cases the class will never be sub-classed, it's easier just to always use static:: and not worry about predicting which classes might have problems in the future. Change-Id: I23072a1701b5acf62bb3379a877de97627d8fcf3
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Tests;
|
|
|
|
use MediaWiki\Extension\DiscussionTools\CommentUtils;
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
/**
|
|
* @coversDefaultClass \MediaWiki\Extension\DiscussionTools\CommentUtils
|
|
*
|
|
* @group DiscussionTools
|
|
*/
|
|
class CommentUtilsTest extends IntegrationTestCase {
|
|
/**
|
|
* @dataProvider provideIsSingleCommentSignedBy
|
|
* @covers ::isSingleCommentSignedBy
|
|
*/
|
|
public function testIsSingleCommentSignedBy(
|
|
string $msg, string $title, string $username, string $html, bool $expected
|
|
) {
|
|
$doc = static::createDocument( $html );
|
|
$container = static::getThreadContainer( $doc );
|
|
|
|
$config = static::getJson( "../data/enwiki-config.json" );
|
|
$data = static::getJson( "../data/enwiki-data.json" );
|
|
$this->setupEnv( $config, $data );
|
|
$title = MediaWikiServices::getInstance()->getTitleParser()->parseTitle( $title );
|
|
$parser = static::createParser( $data );
|
|
|
|
$threadItemSet = $parser->parse( $container, $title );
|
|
$isSigned = CommentUtils::isSingleCommentSignedBy( $threadItemSet, $username, $container );
|
|
static::assertEquals( $expected, $isSigned, $msg );
|
|
}
|
|
|
|
public function provideIsSingleCommentSignedBy(): array {
|
|
return static::getJson( '../cases/isSingleCommentSignedBy.json' );
|
|
}
|
|
}
|