aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/Status/StatusFormatterTest.php
diff options
context:
space:
mode:
authorTim Starling <tstarling@wikimedia.org>2025-02-17 12:36:00 +1100
committerTim Starling <tstarling@wikimedia.org>2025-02-21 12:01:38 +1100
commit1edccf294ac00b304400738a812358e6da252403 (patch)
tree0f414904640a00b0739fae9a83226c2f640f1eb3 /tests/phpunit/includes/Status/StatusFormatterTest.php
parentc40e70a6f8368fc6785c35c739748e5e8d83a47d (diff)
downloadmediawikicore-1edccf294ac00b304400738a812358e6da252403.tar.gz
mediawikicore-1edccf294ac00b304400738a812358e6da252403.zip
Split MessageParser out of MessageCache
MessageCache has enough to do without also being a parser. Split a MessageParser class out of MessageCache and make it a service. * MessageCache::parseWithPostprocessing() becomes MessageParser::parse() because every caller wants postprocessing so it makes sense to use the shorter name for this. * MessageCache::parse() becomes MessageParser ::parseWithoutPostprocessing(). I changed the return type from ParserOutput|string to ParserOutput, which is a followup to I8a1fa84e650d920d07d74722d8059d5afeedec6b. Narrowing the return type does not break b/c so it is possible to make this change for both variants. * In the new methods, a null title is always a convenience alias for a placeholder title (Special:Badtitle). This reflects the convention in Parser::setPage(). The old MessageCache::parse() retains its b/c fallback to $wgTitle. MessageCache::transform() had the potential to fall back to the title used in the previous call, a fragile mechanism which I removed without deprecation. * For consistency, allow a string language in all new methods. * In EmailNotification, clean up an early attempt at global state avoidance. Change-Id: I05ab21508d5f8394189fd41ac6a2254ac0e0d785
Diffstat (limited to 'tests/phpunit/includes/Status/StatusFormatterTest.php')
-rw-r--r--tests/phpunit/includes/Status/StatusFormatterTest.php5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/phpunit/includes/Status/StatusFormatterTest.php b/tests/phpunit/includes/Status/StatusFormatterTest.php
index b16d8064b2a9..289c9c381d41 100644
--- a/tests/phpunit/includes/Status/StatusFormatterTest.php
+++ b/tests/phpunit/includes/Status/StatusFormatterTest.php
@@ -1,6 +1,7 @@
<?php
use MediaWiki\Context\RequestContext;
+use MediaWiki\Language\MessageParser;
use MediaWiki\Language\RawMessage;
use MediaWiki\Message\Message;
use MediaWiki\Parser\ParserOutput;
@@ -37,8 +38,8 @@ class StatusFormatterTest extends MediaWikiLangTestCase {
}
};
- $cache = $this->createNoOpMock( MessageCache::class, [ 'parseWithPostprocessing' ] );
- $cache->method( 'parseWithPostprocessing' )->willReturnCallback(
+ $cache = $this->createNoOpMock( MessageParser::class, [ 'parse' ] );
+ $cache->method( 'parse' )->willReturnCallback(
static function ( $text, ...$args ) {
$text = html_entity_decode( $text, ENT_QUOTES | ENT_HTML5 );
return new ParserOutput( "<p>" . trim( $text ) . "\n</p>" );