2022-02-04 21:58:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Tests;
|
|
|
|
|
|
|
|
use MediaWiki\Extension\DiscussionTools\CommentUtils;
|
2022-02-21 22:07:38 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2022-02-04 21:58:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @group DiscussionTools
|
2022-09-15 12:08:30 +00:00
|
|
|
* @covers \MediaWiki\Extension\DiscussionTools\CommentUtils
|
2022-02-04 21:58:20 +00:00
|
|
|
*/
|
|
|
|
class CommentUtilsTest extends IntegrationTestCase {
|
|
|
|
/**
|
|
|
|
* @dataProvider provideIsSingleCommentSignedBy
|
|
|
|
*/
|
|
|
|
public function testIsSingleCommentSignedBy(
|
|
|
|
string $msg, string $title, string $username, string $html, bool $expected
|
|
|
|
) {
|
2022-06-09 13:51:33 +00:00
|
|
|
$doc = static::createDocument( $html );
|
|
|
|
$container = static::getThreadContainer( $doc );
|
2022-02-04 21:58:20 +00:00
|
|
|
|
2022-06-09 13:51:33 +00:00
|
|
|
$config = static::getJson( "../data/enwiki-config.json" );
|
|
|
|
$data = static::getJson( "../data/enwiki-data.json" );
|
2022-02-04 21:58:20 +00:00
|
|
|
$this->setupEnv( $config, $data );
|
2022-02-21 22:07:38 +00:00
|
|
|
$title = MediaWikiServices::getInstance()->getTitleParser()->parseTitle( $title );
|
2022-06-09 13:51:33 +00:00
|
|
|
$parser = static::createParser( $data );
|
2022-02-04 21:58:20 +00:00
|
|
|
|
2022-03-09 19:32:51 +00:00
|
|
|
$threadItemSet = $parser->parse( $container, $title );
|
|
|
|
$isSigned = CommentUtils::isSingleCommentSignedBy( $threadItemSet, $username, $container );
|
2022-06-09 13:51:33 +00:00
|
|
|
static::assertEquals( $expected, $isSigned, $msg );
|
2022-02-04 21:58:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function provideIsSingleCommentSignedBy(): array {
|
2022-06-09 13:51:33 +00:00
|
|
|
return static::getJson( '../cases/isSingleCommentSignedBy.json' );
|
2022-02-04 21:58:20 +00:00
|
|
|
}
|
|
|
|
}
|