summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/Translate/tests/phpunit/MessageGroupsTest.php')
-rw-r--r--MLEB/Translate/tests/phpunit/MessageGroupsTest.php24
1 files changed, 16 insertions, 8 deletions
diff --git a/MLEB/Translate/tests/phpunit/MessageGroupsTest.php b/MLEB/Translate/tests/phpunit/MessageGroupsTest.php
index 2770683c..adc49e4a 100644
--- a/MLEB/Translate/tests/phpunit/MessageGroupsTest.php
+++ b/MLEB/Translate/tests/phpunit/MessageGroupsTest.php
@@ -1,7 +1,5 @@
<?php
/**
- * Unit tests.
- *
* @author Niklas Laxström
* @file
* @license GPL-2.0-or-later
@@ -11,22 +9,23 @@
* @group Database
* ^ See AggregateMessageGroup::getGroups -> MessageGroups::getPriority
*/
-class MessageGroupsTest extends MediaWikiTestCase {
- protected function setUp() {
+class MessageGroupsTest extends MediaWikiIntegrationTestCase {
+ protected function setUp() : void {
parent::setUp();
$conf = [
__DIR__ . '/data/ParentGroups.yaml',
+ __DIR__ . '/data/ValidatorGroup.yaml'
];
- global $wgHooks;
$this->setMwGlobals( [
- 'wgHooks' => $wgHooks,
'wgTranslateGroupFiles' => $conf,
'wgTranslateTranslationServices' => [],
'wgTranslateMessageNamespaces' => [ NS_MEDIAWIKI ],
] );
- $wgHooks['TranslatePostInitGroups'] = [ 'MessageGroups::getConfiguredGroups' ];
+
+ $this->setTemporaryHook( 'TranslateInitGroupLoaders',
+ 'FileBasedMessageGroupLoader::registerLoader' );
$mg = MessageGroups::singleton();
$mg->setCache( new WANObjectCache( [ 'cache' => wfGetCache( 'hash' ) ] ) );
@@ -83,8 +82,17 @@ class MessageGroupsTest extends MediaWikiTestCase {
$this->assertEquals( 'en', MessageGroups::haveSingleSourceLanguage(
[ $enGroup1, $enGroup2 ] )
);
- $this->assertEquals( '', MessageGroups::haveSingleSourceLanguage(
+ $this->assertSame( '', MessageGroups::haveSingleSourceLanguage(
[ $enGroup1, $enGroup2, $teGroup1 ] )
);
}
+
+ public function testGroupYAMLParsing() {
+ $group = MessageGroups::getGroup( 'test-validator-group' );
+ $msgValidator = $group->getValidator();
+ $suggester = $group->getInsertablesSuggester();
+
+ $this->assertCount( 1, $msgValidator->getValidators() );
+ $this->assertCount( 2, $suggester->getInsertables( "$1 \case" ) );
+ }
}