2019-12-10 15:28:02 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Cite\Tests;
|
|
|
|
|
2023-08-19 04:13:55 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2019-12-10 15:28:02 +00:00
|
|
|
use ParserOptions;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group Database
|
|
|
|
*
|
|
|
|
* @license GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
class CiteDbTest extends \MediaWikiIntegrationTestCase {
|
2023-08-11 14:06:05 +00:00
|
|
|
/** @inheritDoc */
|
|
|
|
protected $tablesUsed = [ 'page' ];
|
2019-12-10 15:28:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Edge case where a 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
|
|
|
* @covers \Cite\ReferenceStack::pushRef
|
|
|
|
*/
|
|
|
|
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'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|