mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Simplify ErrorReporter mocks in tests
In some tests we want to see the message parameters. But not here. Simply echoing the message key (thats parameter number one) is enough. Change-Id: Id9824cbbe944c84c9fd1932b0863ac1b3f232b75
This commit is contained in:
parent
e9d8aa1f25
commit
f3b732bf93
|
@ -135,9 +135,7 @@ class CiteTest extends \MediaWikiIntegrationTestCase {
|
|||
/** @var Cite $spy */
|
||||
$spy = TestingAccessWrapper::newFromObject( $cite );
|
||||
$spy->errorReporter = $this->createPartialMock( ErrorReporter::class, [ 'halfParsed' ] );
|
||||
$spy->errorReporter->method( 'halfParsed' )->willReturnCallback(
|
||||
static fn ( $parser, ...$args ) => '(' . implode( '|', $args ) . ')'
|
||||
);
|
||||
$spy->errorReporter->method( 'halfParsed' )->willReturnArgument( 1 );
|
||||
$spy->referenceListFormatter = $this->createMock( ReferenceListFormatter::class );
|
||||
$spy->referenceListFormatter->method( 'formatReferences' )
|
||||
->with( $parser, [], $expectedResponsive, false )
|
||||
|
@ -195,7 +193,7 @@ class CiteTest extends \MediaWikiIntegrationTestCase {
|
|||
'expectedRollbackCount' => 0,
|
||||
'expectedInReferencesGroup' => '',
|
||||
'expectedResponsive' => false,
|
||||
'expectedOutput' => '(cite_error_references_invalid_parameters)',
|
||||
'expectedOutput' => 'cite_error_references_invalid_parameters',
|
||||
],
|
||||
'Contains refs (which are broken)' => [
|
||||
'text' => Parser::MARKER_PREFIX . '-ref- and ' . Parser::MARKER_PREFIX . '-notref-',
|
||||
|
@ -203,7 +201,7 @@ class CiteTest extends \MediaWikiIntegrationTestCase {
|
|||
'expectedRollbackCount' => 1,
|
||||
'expectedInReferencesGroup' => '',
|
||||
'expectedResponsive' => false,
|
||||
'expectedOutput' => "references!\n(cite_error_references_no_key)"
|
||||
'expectedOutput' => "references!\ncite_error_references_no_key"
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -226,10 +224,8 @@ class CiteTest extends \MediaWikiIntegrationTestCase {
|
|||
$mockParser->method( 'getStripState' )
|
||||
->willReturn( $this->createMock( StripState::class ) );
|
||||
|
||||
$errorReporter = $this->createPartialMock( ErrorReporter::class, [ 'halfParsed', 'plain' ] );
|
||||
$errorReporter->method( $this->logicalOr( 'halfParsed', 'plain' ) )->willReturnCallback(
|
||||
static fn ( $parser, ...$args ) => '(' . implode( '|', $args ) . ')'
|
||||
);
|
||||
$errorReporter = $this->createPartialMock( ErrorReporter::class, [ 'halfParsed' ] );
|
||||
$errorReporter->method( 'halfParsed' )->willReturnArgument( 1 );
|
||||
|
||||
$referenceStack = new ReferenceStack();
|
||||
/** @var ReferenceStack $stackSpy */
|
||||
|
@ -337,7 +333,7 @@ class CiteTest extends \MediaWikiIntegrationTestCase {
|
|||
],
|
||||
'inReferencesGroup' => null,
|
||||
'initialRefs' => [],
|
||||
'expectedOutput' => '(cite_error_ref_too_many_keys)',
|
||||
'expectedOutput' => 'cite_error_ref_too_many_keys',
|
||||
'expectedError' => null,
|
||||
'expectedRefs' => []
|
||||
],
|
||||
|
|
|
@ -199,9 +199,7 @@ class ReferenceListFormatterTest extends \MediaWikiUnitTestCase {
|
|||
string $expectedOutput
|
||||
) {
|
||||
$mockErrorReporter = $this->createMock( ErrorReporter::class );
|
||||
$mockErrorReporter->method( 'plain' )->willReturnCallback(
|
||||
static fn ( $parser, ...$args ) => '(' . implode( '|', $args ) . ')'
|
||||
);
|
||||
$mockErrorReporter->method( 'plain' )->willReturnArgument( 1 );
|
||||
|
||||
$anchorFormatter = $this->createMock( AnchorFormatter::class );
|
||||
$anchorFormatter->method( 'backLink' )->willReturnCallback(
|
||||
|
@ -291,9 +289,9 @@ class ReferenceListFormatterTest extends \MediaWikiUnitTestCase {
|
|||
'expectedOutput' => '(cite_references_link_many|1-5|(cite_references_link_many_format|1+5-0|3.0|' .
|
||||
'(cite_references_link_many_format_backlink_labels))' .
|
||||
'(cite_references_link_many_sep)(cite_references_link_many_format|1+5-1|3.1|' .
|
||||
'(cite_error_references_no_backlink_label))(cite_references_link_many_and)' .
|
||||
'(cite_references_link_many_format|1+5-2|3.2|(cite_error_references_no_backlink_label' .
|
||||
'))|<span class="reference-text">t</span>' . "\n|)"
|
||||
'cite_error_references_no_backlink_label)(cite_references_link_many_and)' .
|
||||
'(cite_references_link_many_format|1+5-2|3.2|cite_error_references_no_backlink_label' .
|
||||
')|<span class="reference-text">t</span>' . "\n|)"
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue