summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/tests/phpunit/SolrTTMServerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/Translate/tests/phpunit/SolrTTMServerTest.php')
-rw-r--r--www/wiki/extensions/Translate/tests/phpunit/SolrTTMServerTest.php33
1 files changed, 18 insertions, 15 deletions
diff --git a/www/wiki/extensions/Translate/tests/phpunit/SolrTTMServerTest.php b/www/wiki/extensions/Translate/tests/phpunit/SolrTTMServerTest.php
index bbf19c20..36bc0b30 100644
--- a/www/wiki/extensions/Translate/tests/phpunit/SolrTTMServerTest.php
+++ b/www/wiki/extensions/Translate/tests/phpunit/SolrTTMServerTest.php
@@ -1,10 +1,8 @@
<?php
/**
- * Tests for SolrTTMServer
- *
* @file
* @author Niklas Laxström
- * @license GPL-2.0+
+ * @license GPL-2.0-or-later
*/
/**
@@ -15,17 +13,22 @@ class SolrTTMServerTest extends MediaWikiTestCase {
protected function setUp() {
parent::setUp();
- global $wgHooks, $wgTranslateTranslationServices, $wgTranslateTestTTMServer;
- $this->setMwGlobals( array(
+ global $wgHooks,
+ $wgTranslateTranslationServices,
+ $wgTranslateTranslationDefaultService,
+ $wgTranslateTestTTMServer;
+ $this->setMwGlobals( [
'wgHooks' => $wgHooks,
- 'wgTranslateTranslationServices' => array(),
- ) );
- $wgTranslateTranslationServices['TTMServer'] = $wgTranslateTestTTMServer;
+ 'wgTranslateTranslationServices' => [],
+ ] );
+ // because var names are too long...
+ $default = $wgTranslateTranslationDefaultService;
+ $wgTranslateTranslationServices[$default] = $wgTranslateTestTTMServer;
- $wgHooks['TranslatePostInitGroups'] = array( array( $this, 'addGroups' ) );
+ $wgHooks['TranslatePostInitGroups'] = [ [ $this, 'addGroups' ] ];
$mg = MessageGroups::singleton();
- $mg->setCache( wfGetCache( 'hash' ) );
+ $mg->setCache( new WANObjectCache( [ 'cache' => wfGetCache( 'hash' ) ] ) );
$mg->recache();
MessageIndex::setInstance( new HashMessageIndex() );
@@ -33,8 +36,8 @@ class SolrTTMServerTest extends MediaWikiTestCase {
}
public function addGroups( &$list ) {
- $list['ttmserver-test'] = new MockWikiMessageGroup( 'ttmserver-test', array(
- 'one' => '1', 'two' => 'kaksi', 'three' => '3' ) );
+ $list['ttmserver-test'] = new MockWikiMessageGroup( 'ttmserver-test', [
+ 'one' => '1', 'two' => 'kaksi', 'three' => '3' ] );
return true;
}
@@ -79,7 +82,7 @@ class SolrTTMServerTest extends MediaWikiTestCase {
$this->assertEquals( wfWikiID(), $doc->wiki );
$this->assertEquals( 'en', $doc->language );
$this->assertEquals( '1', $doc->content );
- $this->assertEquals( array( 'ttmserver-test' ), $doc->group );
+ $this->assertEquals( [ 'ttmserver-test' ], $doc->group );
// Add one translation
$title = Title::newFromText( 'MediaWiki:one/fi' );
@@ -97,7 +100,7 @@ class SolrTTMServerTest extends MediaWikiTestCase {
// @todo FIXME Empty foreach statement.
}
$this->assertEquals( 'yksi', $doc->content );
- $this->assertEquals( array( 'ttmserver-test' ), $doc->group );
+ $this->assertEquals( [ 'ttmserver-test' ], $doc->group );
// Update definition
$title = Title::newFromText( 'MediaWiki:one/en' );
@@ -139,7 +142,7 @@ class SolrTTMServerTest extends MediaWikiTestCase {
// And now the messages should be orphaned
global $wgHooks;
- $wgHooks['TranslatePostInitGroups'] = array();
+ $wgHooks['TranslatePostInitGroups'] = [];
MessageGroups::singleton()->recache();
MessageIndex::singleton()->rebuild();
self::runJobs();