| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\Message\Message; |
| 4 |
use MediaWiki\Message\MessageFormatterFactory; |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
class MessageFormatterFactoryTest extends MediaWikiUnitTestCase { |
| 10 |
use MediaWikiCoversValidator; |
| 11 |
|
| 12 |
public static function provideGetTextFormatter() { |
| 13 |
yield [ 'en', null ]; |
| 14 |
yield [ 'en', Message::FORMAT_TEXT ]; |
| 15 |
yield [ 'ru', Message::FORMAT_PLAIN ]; |
| 16 |
} |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
public function testGetTextFormatter( string $lang, ?string $format = null ) { |
| 25 |
if ( $format ) { |
| 26 |
$factory = new MessageFormatterFactory( $format ); |
| 27 |
} else { |
| 28 |
$factory = new MessageFormatterFactory(); |
| 29 |
} |
| 30 |
$formatter = $factory->getTextFormatter( $lang ); |
| 31 |
$this->assertSame( $lang, $formatter->getLangCode() ); |
| 32 |
} |
| 33 |
} |