From fdd2df0a807ae89d1d869bd71768494a183f5337 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Mon, 13 Aug 2012 10:18:18 +0200 Subject: [PATCH] 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 --- tests/phpunit/includes/UserTest.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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.' + ); + } } -- 2.20.1