From: umherirrender Date: Mon, 13 Aug 2012 08:18:18 +0000 (+0200) Subject: Add UserTest::testAllRightsWithMessage X-Git-Tag: 1.31.0-rc.0~22716^2 X-Git-Url: http://git.cyclocoop.org/%22%20%20.%20generer_url_ecrire%28%22mots_tous%22%29%20.%20%22?a=commitdiff_plain;h=fdd2df0a807ae89d1d869bd71768494a183f5337;p=lhc%2Fweb%2Fwiklou.git Add UserTest::testAllRightsWithMessage New test case, which checked, if for all available rights a right- message exist (Core and Extensions) Some missing rights added with extra patch sets (need merge/rebasing before merge of this) Change-Id: I28957835fb77a01a799439ad7b3d22b96db07204 --- diff --git a/tests/phpunit/includes/UserTest.php b/tests/phpunit/includes/UserTest.php index ef03e83547..7a424aef16 100644 --- a/tests/phpunit/includes/UserTest.php +++ b/tests/phpunit/includes/UserTest.php @@ -140,4 +140,32 @@ class UserTest extends MediaWikiTestCase { array( 'Ab cd', false, ' Ideographic space' ), ); } + + /** + * Test, if for all rights a right- message exist, + * which is used on Special:ListGroupRights as help text + * Extensions and core + */ + public function testAllRightsWithMessage() { + //Getting all user rights, for core: User::$mCoreRights, for extensions: $wgAvailableRights + $allRights = User::getAllRights(); + $allMessageKeys = Language::getMessageKeysFor( 'en' ); + + $rightsWithMessage = array(); + foreach ( $allMessageKeys as $message ) { + // === 0: must be at beginning of string (position 0) + if ( strpos( $message, 'right-' ) === 0 ) { + $rightsWithMessage[] = substr( $message, strlen( 'right-' ) ); + } + } + + sort( $allRights ); + sort( $rightsWithMessage ); + + $this->assertEquals( + $allRights, + $rightsWithMessage, + 'Each user rights (core/extensions) has a corresponding right- message.' + ); + } }