X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fqunit%2Fdata%2FgenerateJqueryMsgData.php;h=1c79f6d12e61e2fed96dc16e1035c338c2ceeb27;hb=d17eeb742a26c2567de96872c0419b39b97cde56;hp=61ebbf8fc607483a4f4e451067032030281704a8;hpb=9f983794066756ddc02d641029f7d960c3c24e0f;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/qunit/data/generateJqueryMsgData.php b/tests/qunit/data/generateJqueryMsgData.php index 61ebbf8fc6..1c79f6d12e 100644 --- a/tests/qunit/data/generateJqueryMsgData.php +++ b/tests/qunit/data/generateJqueryMsgData.php @@ -16,7 +16,7 @@ /* * @example QUnit * - QUnit.test( 'Output matches PHP parser', mw.libs.phpParserData.tests.length, function ( assert ) { + QUnit.test( 'Output matches PHP parser', function ( assert ) { mw.messages.set( mw.libs.phpParserData.messages ); $.each( mw.libs.phpParserData.tests, function ( i, test ) { QUnit.stop(); @@ -65,22 +65,22 @@ require __DIR__ . '/../../../maintenance/Maintenance.php'; class GenerateJqueryMsgData extends Maintenance { - public static $keyToTestArgs = array( - 'undelete_short' => array( - array( 0 ), - array( 1 ), - array( 2 ), - array( 5 ), - array( 21 ), - array( 101 ) - ), - 'category-subcat-count' => array( - array( 0, 10 ), - array( 1, 1 ), - array( 1, 2 ), - array( 3, 30 ) - ) - ); + public static $keyToTestArgs = [ + 'undelete_short' => [ + [ 0 ], + [ 1 ], + [ 2 ], + [ 5 ], + [ 21 ], + [ 101 ] + ], + 'category-subcat-count' => [ + [ 0, 10 ], + [ 1, 1 ], + [ 1, 2 ], + [ 3, 30 ] + ] + ]; public function __construct() { parent::__construct(); @@ -94,9 +94,9 @@ class GenerateJqueryMsgData extends Maintenance { } private function getMessagesAndTests() { - $messages = array(); - $tests = array(); - foreach ( array( 'en', 'fr', 'ar', 'jp', 'zh' ) as $languageCode ) { + $messages = []; + $tests = []; + foreach ( [ 'en', 'fr', 'ar', 'jp', 'zh' ] as $languageCode ) { foreach ( self::$keyToTestArgs as $key => $testArgs ) { foreach ( $testArgs as $args ) { // Get the raw message, without any transformations. @@ -109,32 +109,31 @@ class GenerateJqueryMsgData extends Maintenance { // fake multiple languages by flattening them together. $langKey = $languageCode . '_' . $key; $messages[$langKey] = $template; - $tests[] = array( - 'name' => $languageCode . ' ' . $key . ' ' . join( ',', $args ), + $tests[] = [ + 'name' => $languageCode . ' ' . $key . ' ' . implode( ',', $args ), 'key' => $langKey, 'args' => $args, 'result' => $result, 'lang' => $languageCode - ); + ]; } } } - return array( $messages, $tests ); + return [ $messages, $tests ]; } private function writeJavascriptFile( $messages, $tests, $dataSpecFile ) { - $phpParserData = array( + $phpParserData = [ 'messages' => $messages, 'tests' => $tests, - ); + ]; $output = "// This file stores the output from the PHP parser for various messages, arguments,\n" . "// languages, and parser modes. Intended for use by a unit test framework by looping\n" . "// through the object and comparing its parser return value with the 'result' property.\n" . '// Last generated with ' . basename( __FILE__ ) . ' at ' . gmdate( 'r' ) . "\n" - // This file will contain unquoted JSON strings as javascript native object literals, - // flip the quotemark convention for this file. + . "/* eslint-disable */\n" . "\n" . 'mediaWiki.libs.phpParserData = ' . FormatJson::encode( $phpParserData, true ) . ";\n";