Umherirrender has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/169579

Change subject: Tests: Compare en.json and qqq.json message keys
......................................................................

Tests: Compare en.json and qqq.json message keys

Bug: 35942
Change-Id: Ieb7759057867b73b368749202610370fb3b18811
---
A tests/phpunit/structure/MessageKeyTest.php
1 file changed, 40 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/79/169579/1

diff --git a/tests/phpunit/structure/MessageKeyTest.php 
b/tests/phpunit/structure/MessageKeyTest.php
new file mode 100644
index 0000000..8748f13
--- /dev/null
+++ b/tests/phpunit/structure/MessageKeyTest.php
@@ -0,0 +1,40 @@
+<?php
+
+class MessageKeyTest extends MediaWikiTestCase {
+       /**
+        * Assert that there for each english message key a message key in the 
qqq file exists,
+        * which contains a message documentation for translators.
+        * It can also use templates from translatewiki.net
+        */
+       public function testMessageKeys() {
+               global $wgMessagesDirs;
+
+               $lcache = Language::getLocalisationCache();
+               $messageKeysEn = array();
+               $messageKeysQqq = array();
+               foreach ( $wgMessagesDirs as $dirs ) {
+                       foreach ( (array)$dirs as $dir ) {
+                               $dataEn = $lcache->readJSONFile( "$dir/en.json" 
);
+                               $messageKeysEn = array_merge( $messageKeysEn, 
$dataEn['messages'] );
+
+                               $dataQqq = $lcache->readJSONFile( 
"$dir/qqq.json" );
+                               $messageKeysQqq = array_merge( $messageKeysQqq, 
$dataQqq['messages'] );
+                       }
+               }
+
+               // Remove all the same keys to make the assertEquals output 
nicer/smaller
+               foreach ( $messageKeysEn as $key => $data ) {
+                       if ( isset( $messageKeysQqq[$key] ) ) {
+                               unset( $messageKeysEn[$key] );
+                               unset( $messageKeysQqq[$key] );
+                       }
+               }
+
+               // Not using assertEmpty to get all the keys as a diff
+               $this->assertEquals(
+                       array_keys( $messageKeysEn ),
+                       array_keys( $messageKeysQqq ),
+                       'Each english message should have a message 
documentation in language file \'qqq\''
+               );
+       }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/169579
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieb7759057867b73b368749202610370fb3b18811
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <umherirrender_de...@web.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to