mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-18 01:30:32 +00:00
2ff327df53
> We lose useful coverage and spend valuable time keeping these tags > accurate through refactors (or worse, forget to do so). > > I am not disabling the "only track coverage of specified subject" > benefits, nor am I claiming coverage in in classes outside the > subject under test. > > Tracking tiny per-method details wastes time in keeping tags > in sync during refactors, and time to realize (and fix) when people > inevitably don't keep them in sync, and time lost in finding > uncovered code to write tests for only to realize it was already > covered but "not yet claimed". https://gerrit.wikimedia.org/r/q/owner:Krinkle+is:merged+message:%2522Widen%2522 Change-Id: Iafa241210b81ba1cbfee74e3920fb044c86d09fc
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Cite\Tests;
|
|
|
|
use MediaWiki\Title\Title;
|
|
use ParserOptions;
|
|
|
|
/**
|
|
* @group Database
|
|
* @covers \Cite\ReferenceStack
|
|
* @license GPL-2.0-or-later
|
|
*/
|
|
class CiteDbTest extends \MediaWikiIntegrationTestCase {
|
|
/** @inheritDoc */
|
|
protected $tablesUsed = [ 'page' ];
|
|
|
|
/**
|
|
* Parser call within `<ref>` parse clears the original parser state.
|
|
* @see https://phabricator.wikimedia.org/T240248
|
|
*/
|
|
public function testReferenceStackError() {
|
|
$this->insertPage( 'Cite-tracking-category-cite-error', '{{PAGENAME}}', NS_MEDIAWIKI );
|
|
|
|
$services = $this->getServiceContainer();
|
|
// 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()
|
|
);
|
|
|
|
$this->assertStringContainsString(
|
|
'cite_ref-2',
|
|
$parserOutput->getText(),
|
|
'Internal counter should not reset to 1 for text #3'
|
|
);
|
|
}
|
|
|
|
}
|