summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/tests/phpunit/api/ApiTranslationReviewTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/Translate/tests/phpunit/api/ApiTranslationReviewTest.php')
-rw-r--r--www/wiki/extensions/Translate/tests/phpunit/api/ApiTranslationReviewTest.php54
1 files changed, 28 insertions, 26 deletions
diff --git a/www/wiki/extensions/Translate/tests/phpunit/api/ApiTranslationReviewTest.php b/www/wiki/extensions/Translate/tests/phpunit/api/ApiTranslationReviewTest.php
index 4710a306..930dad0e 100644
--- a/www/wiki/extensions/Translate/tests/phpunit/api/ApiTranslationReviewTest.php
+++ b/www/wiki/extensions/Translate/tests/phpunit/api/ApiTranslationReviewTest.php
@@ -3,7 +3,7 @@
*
* @file
* @author Niklas Laxström
- * @license GPL-2.0+
+ * @license GPL-2.0-or-later
*/
/**
@@ -14,14 +14,18 @@ class ApiTranslationReviewTest extends MediaWikiTestCase {
parent::setUp();
global $wgHooks;
- $this->setMwGlobals( array(
+ $this->setMwGlobals( [
'wgHooks' => $wgHooks,
- 'wgGroupPermissions' => array(),
- 'wgTranslateMessageNamespaces' => array( NS_MEDIAWIKI ),
- ) );
- $wgHooks['TranslatePostInitGroups'] = array( array( $this, 'getTestGroups' ) );
+ 'wgGroupPermissions' => [
+ 'sysop' => [
+ 'translate-messagereview' => true,
+ ],
+ ],
+ 'wgTranslateMessageNamespaces' => [ NS_MEDIAWIKI ],
+ ] );
+ $wgHooks['TranslatePostInitGroups'] = [ [ $this, 'getTestGroups' ] ];
$mg = MessageGroups::singleton();
- $mg->setCache( wfGetCache( 'hash' ) );
+ $mg->setCache( new WANObjectCache( [ 'cache' => wfGetCache( 'hash' ) ] ) );
$mg->recache();
MessageIndex::setInstance( new HashMessageIndex() );
@@ -29,10 +33,10 @@ class ApiTranslationReviewTest extends MediaWikiTestCase {
}
public function getTestGroups( &$list ) {
- $messages = array(
+ $messages = [
'ugakey1' => 'value1',
'ugakey2' => 'value2',
- );
+ ];
$list['testgroup'] = new MockWikiMessageGroup( 'testgroup', $messages );
@@ -40,13 +44,11 @@ class ApiTranslationReviewTest extends MediaWikiTestCase {
}
public function testgetReviewBlockers() {
- $superUser1 = new MockSuperUser();
- $superUser1->setId( 1 );
+ $superUser1 = $this->getMutableTestUser( [ 'sysop', 'bureaucrat' ] )->getUser();
- $superUser2 = new MockSuperUser();
- $superUser2->setId( 2 );
+ $superUser2 = $this->getMutableTestUser( [ 'sysop', 'bureaucrat' ] )->getUser();
- $plainUser = User::newFromName( 'PlainUser' );
+ $plainUser = $this->getMutableTestUser()->getUser();
$title = Title::makeTitle( NS_MEDIAWIKI, 'Ugakey1/fi' );
$content = ContentHandler::makeContent( 'trans1', $title );
@@ -60,38 +62,38 @@ class ApiTranslationReviewTest extends MediaWikiTestCase {
$content = ContentHandler::makeContent( 'unknown message', $title );
WikiPage::factory( $title )->doEditContent( $content, __METHOD__, 0, false, $superUser1 );
- $testcases = array(
- array(
+ $testcases = [
+ [
'permissiondenied',
$plainUser,
'Ugakey1/fi',
'Unpriviledged user is not allowed to change state'
- ),
- array(
+ ],
+ [
'owntranslation',
$superUser1,
'Ugakey1/fi',
'Cannot approve own translation'
- ),
- array(
+ ],
+ [
'fuzzymessage',
$superUser1,
'Ugakey2/fi',
'Cannot approve fuzzy translation'
- ),
- array(
+ ],
+ [
'unknownmessage',
$superUser1,
'Ugakey3/fi',
'Cannot approve unknown translation'
- ),
- array(
+ ],
+ [
'',
$superUser2,
'Ugakey1/fi',
'Can approve non-fuzzy known non-own translation'
- ),
- );
+ ],
+ ];
foreach ( $testcases as $case ) {
list( $expected, $user, $page, $comment ) = $case;