2019-12-10 15:28:02 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Cite\Tests;
|
|
|
|
|
2024-10-19 21:25:16 +00:00
|
|
|
use MediaWiki\Parser\ParserOptions;
|
2023-08-19 04:13:55 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2019-12-10 15:28:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @group Database
|
2023-12-14 01:53:19 +00:00
|
|
|
* @covers \Cite\ReferenceStack
|
2019-12-10 15:28:02 +00:00
|
|
|
* @license GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
class CiteDbTest extends \MediaWikiIntegrationTestCase {
|
|
|
|
/**
|
2023-12-14 01:53:19 +00:00
|
|
|
* Parser call within `<ref>` parse clears the original parser state.
|
2019-12-20 18:31:54 +00:00
|
|
|
* @see https://phabricator.wikimedia.org/T240248
|
2019-12-10 15:28:02 +00:00
|
|
|
*/
|
|
|
|
public function testReferenceStackError() {
|
|
|
|
$this->insertPage( 'Cite-tracking-category-cite-error', '{{PAGENAME}}', NS_MEDIAWIKI );
|
|
|
|
|
2023-10-26 19:55:00 +00:00
|
|
|
$services = $this->getServiceContainer();
|
2019-12-10 15:28:02 +00:00
|
|
|
// Reset the MessageCache in order to force it to clone a new parser.
|
|
|
|
$services->resetServiceForTesting( 'MessageCache' );
|
|
|
|
$services->getMessageCache()->enable();
|
|
|
|
|
|
|
|
$parserOutput = $services->getParser()->parse(
|
|
|
|
'
|
|
|
|
<ref name="a">text #1</ref>
|
|
|
|
<ref name="a">text #2</ref>
|
|
|
|
<ref>text #3</ref>
|
|
|
|
',
|
|
|
|
Title::makeTitle( NS_MAIN, mt_rand() ),
|
|
|
|
ParserOptions::newFromAnon()
|
|
|
|
);
|
|
|
|
|
2020-01-19 20:39:12 +00:00
|
|
|
$this->assertStringContainsString(
|
2019-12-10 15:28:02 +00:00
|
|
|
'cite_ref-2',
|
|
|
|
$parserOutput->getText(),
|
|
|
|
'Internal counter should not reset to 1 for text #3'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|