mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-27 16:30:12 +00:00
Merge "Update tests for PHPUnit 9.6"
This commit is contained in:
commit
3462165a56
|
@ -33,12 +33,11 @@ class CitationToolDefinitionTest extends \MediaWikiUnitTestCase {
|
|||
|
||||
$context = $this->createStub( Context::class );
|
||||
$context->method( 'msg' )
|
||||
->withConsecutive(
|
||||
[ 'cite-tool-definition.json' ],
|
||||
[ 'visualeditor-cite-tool-definition.json' ],
|
||||
[ 'visualeditor-cite-tool-name-n' ]
|
||||
)
|
||||
->willReturn( $msg );
|
||||
->willReturnMap( [
|
||||
[ 'cite-tool-definition.json', $msg ],
|
||||
[ 'visualeditor-cite-tool-definition.json', $msg ],
|
||||
[ 'visualeditor-cite-tool-name-n', $msg ]
|
||||
] );
|
||||
$context->method( 'encodeJson' )->willReturnCallback( 'json_encode' );
|
||||
return $context;
|
||||
}
|
||||
|
|
|
@ -21,12 +21,13 @@ class CiteParserHooksTest extends \MediaWikiUnitTestCase {
|
|||
*/
|
||||
public function testOnParserFirstCallInit() {
|
||||
$parser = $this->createNoOpMock( Parser::class, [ 'setHook' ] );
|
||||
$expectedTags = [ 'ref' => true, 'references' => true ];
|
||||
$parser->expects( $this->exactly( 2 ) )
|
||||
->method( 'setHook' )
|
||||
->withConsecutive(
|
||||
[ 'ref', $this->isType( 'callable' ) ],
|
||||
[ 'references', $this->isType( 'callable' ) ]
|
||||
);
|
||||
->willReturnCallback( function ( $tag ) use ( &$expectedTags ) {
|
||||
$this->assertArrayHasKey( $tag, $expectedTags );
|
||||
unset( $expectedTags[$tag] );
|
||||
} );
|
||||
|
||||
$citeParserHooks = new CiteParserHooks();
|
||||
$citeParserHooks->onParserFirstCallInit( $parser );
|
||||
|
|
|
@ -20,12 +20,13 @@ class CiteParserTagHooksTest extends \MediaWikiUnitTestCase {
|
|||
*/
|
||||
public function testRegister() {
|
||||
$parser = $this->createNoOpMock( Parser::class, [ 'setHook' ] );
|
||||
$expectedTags = [ 'ref' => true, 'references' => true ];
|
||||
$parser->expects( $this->exactly( 2 ) )
|
||||
->method( 'setHook' )
|
||||
->withConsecutive(
|
||||
[ 'ref', $this->isType( 'callable' ) ],
|
||||
[ 'references', $this->isType( 'callable' ) ]
|
||||
);
|
||||
->willReturnCallback( function ( $tag ) use ( &$expectedTags ) {
|
||||
$this->assertArrayHasKey( $tag, $expectedTags );
|
||||
unset( $expectedTags[$tag] );
|
||||
} );
|
||||
|
||||
CiteParserTagHooks::register( $parser );
|
||||
}
|
||||
|
|
|
@ -89,7 +89,11 @@ class ErrorReporterTest extends \MediaWikiUnitTestCase {
|
|||
$parser = $this->createNoOpMock( Parser::class, [ 'addTrackingCategory', 'getOptions', 'recursiveTagParse' ] );
|
||||
$parser->expects( $this->exactly( count( $expectedCategories ) ) )
|
||||
->method( 'addTrackingCategory' )
|
||||
->withConsecutive( $expectedCategories );
|
||||
->willReturnCallback( function ( $cat ) use ( &$expectedCategories ) {
|
||||
$catIdx = array_search( $cat, $expectedCategories, true );
|
||||
$this->assertNotFalse( $catIdx, "Unexpected category: $cat" );
|
||||
unset( $expectedCategories[$catIdx] );
|
||||
} );
|
||||
$parser->method( 'getOptions' )->willReturn( $parserOptions );
|
||||
$parser->method( 'recursiveTagParse' )->willReturnCallback(
|
||||
static function ( $content ) {
|
||||
|
|
Loading…
Reference in a new issue