mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-27 17:51:09 +00:00
Fix parsing of non-English titles in tests
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
This commit is contained in:
parent
aa1accebf1
commit
b68832ace0
|
@ -169,11 +169,11 @@
|
|||
},
|
||||
{
|
||||
"name": "Signature which is just a selflink",
|
||||
"title": "User_talk:Ed",
|
||||
"title": "Dyskusja_wikipedysty:Ed",
|
||||
"dom": "cases/selflink-signature/selflink-signature.html",
|
||||
"expected": "../cases/selflink-signature/selflink-signature.json",
|
||||
"config": "../data/enwiki-config.json",
|
||||
"data": "../data/enwiki-data.json"
|
||||
"config": "../data/plwiki-config.json",
|
||||
"data": "../data/plwiki-data.json"
|
||||
},
|
||||
{
|
||||
"name": "Comments inside references (old parser)",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="mw-parser-output">
|
||||
<h2><span id="Topic"></span><span class="mw-headline" id="Topic">Topic</span></h2>
|
||||
<p>Comment signed on own talk page, with custom signature that links only to this talk page. Link label is also custom. <a class="mw-selflink selflink">Custom talk link label</a> 19:06, 21 August 2019 (UTC)</p>
|
||||
<p>Comment signed on own talk page, with custom signature that links only to this talk page. Link label is also custom. <a class="mw-selflink selflink">Custom talk link label</a> 21:06, 21 sie 2019 (CEST)</p>
|
||||
</div>
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
"author": "Ed",
|
||||
"range": [
|
||||
"3/0",
|
||||
"3/2/28"
|
||||
"3/2/26"
|
||||
],
|
||||
"signatureRanges": [
|
||||
[
|
||||
"3/1",
|
||||
"3/2/28"
|
||||
"3/2/26"
|
||||
]
|
||||
],
|
||||
"level": 1,
|
||||
|
|
|
@ -18,7 +18,6 @@ class CommentFormatterTest extends IntegrationTestCase {
|
|||
public function testAddDiscussionToolsInternal(
|
||||
string $name, string $title, string $dom, string $expected, string $config, string $data
|
||||
): void {
|
||||
$title = Title::newFromText( $title );
|
||||
$dom = self::getHtml( $dom );
|
||||
$expectedPath = $expected;
|
||||
$expected = self::getText( $expected );
|
||||
|
@ -26,6 +25,7 @@ class CommentFormatterTest extends IntegrationTestCase {
|
|||
$data = self::getJson( $data );
|
||||
|
||||
$this->setupEnv( $config, $data );
|
||||
$title = Title::newFromText( $title );
|
||||
MockCommentFormatter::$parser = TestUtils::createParser( $data );
|
||||
|
||||
$commentFormatter = TestingAccessWrapper::newFromClass( MockCommentFormatter::class );
|
||||
|
|
|
@ -23,7 +23,6 @@ class CommentModifierTest extends IntegrationTestCase {
|
|||
string $name, string $title, string $dom, string $expected, string $config, string $data,
|
||||
string $replyIndentation = 'invisible'
|
||||
): void {
|
||||
$title = Title::newFromText( $title );
|
||||
$origPath = $dom;
|
||||
$dom = self::getHtml( $dom );
|
||||
$expectedPath = $expected;
|
||||
|
@ -32,6 +31,7 @@ class CommentModifierTest extends IntegrationTestCase {
|
|||
$data = self::getJson( $data );
|
||||
|
||||
$this->setupEnv( $config, $data );
|
||||
$title = Title::newFromText( $title );
|
||||
|
||||
$doc = self::createDocument( $dom );
|
||||
$container = self::getThreadContainer( $doc );
|
||||
|
@ -68,7 +68,6 @@ class CommentModifierTest extends IntegrationTestCase {
|
|||
public function testAddReplyLink(
|
||||
string $name, string $title, string $dom, string $expected, string $config, string $data
|
||||
): void {
|
||||
$title = Title::newFromText( $title );
|
||||
$origPath = $dom;
|
||||
$dom = self::getHtml( $dom );
|
||||
$expectedPath = $expected;
|
||||
|
@ -77,6 +76,7 @@ class CommentModifierTest extends IntegrationTestCase {
|
|||
$data = self::getJson( $data );
|
||||
|
||||
$this->setupEnv( $config, $data );
|
||||
$title = Title::newFromText( $title );
|
||||
|
||||
$doc = self::createDocument( $dom );
|
||||
$container = self::getThreadContainer( $doc );
|
||||
|
|
|
@ -190,7 +190,6 @@ class CommentParserTest extends IntegrationTestCase {
|
|||
public function testGetThreads(
|
||||
string $name, string $title, string $dom, string $expected, string $config, string $data
|
||||
): void {
|
||||
$title = Title::newFromText( $title );
|
||||
$dom = self::getHtml( $dom );
|
||||
$expectedPath = $expected;
|
||||
$expected = self::getJson( $expected );
|
||||
|
@ -201,6 +200,7 @@ class CommentParserTest extends IntegrationTestCase {
|
|||
$container = self::getThreadContainer( $doc );
|
||||
|
||||
$this->setupEnv( $config, $data );
|
||||
$title = Title::newFromText( $title );
|
||||
$threadItemSet = self::createParser( $data )->parse( $container, $title );
|
||||
$threads = $threadItemSet->getThreads();
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@ class CommentUtilsTest extends IntegrationTestCase {
|
|||
public function testIsSingleCommentSignedBy(
|
||||
string $msg, string $title, string $username, string $html, bool $expected
|
||||
) {
|
||||
$title = Title::newFromText( $title );
|
||||
$doc = self::createDocument( $html );
|
||||
$container = self::getThreadContainer( $doc );
|
||||
|
||||
$config = self::getJson( "../data/enwiki-config.json" );
|
||||
$data = self::getJson( "../data/enwiki-data.json" );
|
||||
$this->setupEnv( $config, $data );
|
||||
$title = Title::newFromText( $title );
|
||||
$parser = self::createParser( $data );
|
||||
|
||||
$threadItemSet = $parser->parse( $container, $title );
|
||||
|
|
|
@ -37,8 +37,8 @@ class EventDispatcherTest extends IntegrationTestCase {
|
|||
$doc2 = self::createDocument( $dom2 );
|
||||
$container2 = self::getThreadContainer( $doc2 );
|
||||
|
||||
$dummyTitle = Title::newFromText( 'Dummy' );
|
||||
$this->setupEnv( $config, $data );
|
||||
$dummyTitle = Title::newFromText( 'Dummy' );
|
||||
$parser = self::createParser( $data );
|
||||
$itemSet1 = $parser->parse( $container1, $dummyTitle );
|
||||
$itemSet2 = $parser->parse( $container2, $dummyTitle );
|
||||
|
|
|
@ -61,7 +61,6 @@ class ThreadItemTest extends IntegrationTestCase {
|
|||
public function testGetTranscludedFrom(
|
||||
string $name, string $title, string $dom, string $expected, string $config, string $data
|
||||
): void {
|
||||
$title = Title::newFromText( $title );
|
||||
$dom = self::getHtml( $dom );
|
||||
$expectedPath = $expected;
|
||||
$expected = self::getJson( $expected );
|
||||
|
@ -69,6 +68,7 @@ class ThreadItemTest extends IntegrationTestCase {
|
|||
$data = self::getJson( $data );
|
||||
|
||||
$this->setupEnv( $config, $data );
|
||||
$title = Title::newFromText( $title );
|
||||
|
||||
$doc = self::createDocument( $dom );
|
||||
$container = self::getThreadContainer( $doc );
|
||||
|
@ -108,7 +108,6 @@ class ThreadItemTest extends IntegrationTestCase {
|
|||
public function testGetText(
|
||||
string $name, string $title, string $dom, string $expected, string $config, string $data
|
||||
): void {
|
||||
$title = Title::newFromText( $title );
|
||||
$dom = self::getHtml( $dom );
|
||||
$expectedPath = $expected;
|
||||
$expected = self::getJson( $expected );
|
||||
|
@ -119,6 +118,7 @@ class ThreadItemTest extends IntegrationTestCase {
|
|||
$container = self::getThreadContainer( $doc );
|
||||
|
||||
$this->setupEnv( $config, $data );
|
||||
$title = Title::newFromText( $title );
|
||||
$threadItemSet = self::createParser( $data )->parse( $container, $title );
|
||||
$items = $threadItemSet->getThreadItems();
|
||||
|
||||
|
@ -154,7 +154,6 @@ class ThreadItemTest extends IntegrationTestCase {
|
|||
public function testGetHTML(
|
||||
string $name, string $title, string $dom, string $expected, string $config, string $data
|
||||
): void {
|
||||
$title = Title::newFromText( $title );
|
||||
$dom = self::getHtml( $dom );
|
||||
$expectedPath = $expected;
|
||||
$expected = self::getJson( $expected );
|
||||
|
@ -165,6 +164,7 @@ class ThreadItemTest extends IntegrationTestCase {
|
|||
$container = self::getThreadContainer( $doc );
|
||||
|
||||
$this->setupEnv( $config, $data );
|
||||
$title = Title::newFromText( $title );
|
||||
$threadItemSet = self::createParser( $data )->parse( $container, $title );
|
||||
$items = $threadItemSet->getThreadItems();
|
||||
|
||||
|
|
Loading…
Reference in a new issue