aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/unit/includes/ListToggleTest.php
diff options
context:
space:
mode:
authorMichael Große <michael.grosse@wikimedia.de>2023-03-14 19:24:11 +0100
committerLucas Werkmeister <lucas.werkmeister@wikimedia.de>2023-03-15 17:55:51 +0100
commit966ea3ad1a201d80331034a44e8dbe04df4d46b9 (patch)
tree1ada0c8338d67e32c5da2f682fdbb33ac6065f8d /tests/phpunit/unit/includes/ListToggleTest.php
parenta04f92ad68f272b621b13678cbe00de91663e108 (diff)
downloadmediawikicore-966ea3ad1a201d80331034a44e8dbe04df4d46b9.tar.gz
mediawikicore-966ea3ad1a201d80331034a44e8dbe04df4d46b9.zip
A fake MessageLocalizer for use in unit tests
The existing MockMessageLocalizer can't be used in unit tests because it uses real Message objects that make a number of database calls via services. Codewise, this is based on \ListToggleTest::testGetHTML and \EntitySchema\MediaWiki\SpecificLanguageMessageLocalizer. It came out from the conversation on I4122bc8b2 Change-Id: I5297e4c43495b7e959798a21929f6d24d0b4b466
Diffstat (limited to 'tests/phpunit/unit/includes/ListToggleTest.php')
-rw-r--r--tests/phpunit/unit/includes/ListToggleTest.php24
1 files changed, 2 insertions, 22 deletions
diff --git a/tests/phpunit/unit/includes/ListToggleTest.php b/tests/phpunit/unit/includes/ListToggleTest.php
index 7eb187be453b..f81f9214ab23 100644
--- a/tests/phpunit/unit/includes/ListToggleTest.php
+++ b/tests/phpunit/unit/includes/ListToggleTest.php
@@ -1,6 +1,7 @@
<?php
use MediaWiki\Html\ListToggle;
+use MediaWiki\Tests\Unit\FakeQqxMessageLocalizer;
/**
* @covers ListToggle
@@ -34,28 +35,7 @@ class ListToggleTest extends MediaWikiUnitTestCase {
$output = $this->createMock( OutputPage::class );
$output->method( 'msg' )
- ->willReturnCallback( static function ( $key ) {
- return new class( $key ) extends Message {
- protected function fetchMessage() {
- return "($this->key$*)";
- }
-
- public function getLanguage() {
- return new class() extends LanguageQqx {
- public function __construct() {
- }
-
- public function getCode() {
- return 'qqx';
- }
- };
- }
-
- protected function transformText( $string ) {
- return $string;
- }
- };
- } );
+ ->willReturnCallback( [ new FakeQqxMessageLocalizer(), 'msg' ] );
$output->expects( $this->once() )
->method( 'getLanguage' )
->willReturn( $language );