Just methods where adding "static" to the declaration was enough, I didn't do anything with providers that used $this. Initially by search and replace. There were many mistakes which I found mostly by running the PHPStorm inspection which searches for $this usage in a static method. Later I used the PHPStorm "make static" action which avoids the more obvious mistakes. Bug: T332865 Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
36 lines
1 KiB
PHP
36 lines
1 KiB
PHP
<?php
|
|
|
|
use MediaWiki\Parser\ParserObserver;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Parser\ParserObserver
|
|
* @group Database
|
|
*/
|
|
class ParserObserverIntegrationTest extends MediaWikiIntegrationTestCase {
|
|
|
|
/**
|
|
* @param bool $duplicate
|
|
* @param int $count
|
|
*
|
|
* @dataProvider provideDuplicateParse
|
|
*/
|
|
public function testDuplicateParse( bool $duplicate, int $count ) {
|
|
$logger = new TestLogger( true );
|
|
$observer = new ParserObserver( $logger );
|
|
$this->setService( '_ParserObserver', $observer );
|
|
$contentRenderer = $this->getServiceContainer()->getContentRenderer();
|
|
// Create a test page. Parse it twice if a duplicate is desired, or once otherwise.
|
|
$page = $this->getExistingTestPage();
|
|
$contentRenderer->getParserOutput( $page->getContent(), $page->getTitle() );
|
|
if ( $duplicate ) {
|
|
$contentRenderer->getParserOutput( $page->getContent(), $page->getTitle() );
|
|
}
|
|
|
|
$this->assertCount( $count, $logger->getBuffer() );
|
|
}
|
|
|
|
public static function provideDuplicateParse() {
|
|
yield [ true, 1 ];
|
|
yield [ false, 0 ];
|
|
}
|
|
}
|