Siebrand has uploaded a new change for review.
https://gerrit.wikimedia.org/r/243162
Change subject: Add tests
......................................................................
Add tests
Fix all issues so tests pass.
Change-Id: I06cedc55c0d64950d94225cc12c1a57b961d06c0
---
M .gitignore
A Gruntfile.js
M SpecialUserOptionStats.php
D UserOptionStats.i18n.php
M UserOptionStats.php
A composer.json
M i18n/en.json
A package.json
A phpcs.xml
9 files changed, 81 insertions(+), 59 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UserOptionStats
refs/changes/62/243162/1
diff --git a/.gitignore b/.gitignore
index c798be9..854a2d2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
-.svn
*~
*.kate-swp
.*.swp
-.idea
+node_modules/
+/composer.lock
+/vendor/
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..9c56558
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,20 @@
+/*jshint node:true */
+module.exports = function ( grunt ) {
+ grunt.loadNpmTasks( 'grunt-banana-checker' );
+ grunt.loadNpmTasks( 'grunt-jsonlint' );
+
+ grunt.initConfig( {
+ banana: {
+ all: 'i18n/'
+ },
+ jsonlint: {
+ all: [
+ '**/*.json',
+ '!node_modules/**'
+ ]
+ }
+ } );
+
+ grunt.registerTask( 'test', [ 'jsonlint', 'banana' ] );
+ grunt.registerTask( 'default', 'test' );
+};
diff --git a/SpecialUserOptionStats.php b/SpecialUserOptionStats.php
index 38b5de7..cc3b98a 100644
--- a/SpecialUserOptionStats.php
+++ b/SpecialUserOptionStats.php
@@ -9,7 +9,7 @@
* @license GPL-2.0+
*/
class SpecialUserOptionStats extends SpecialPage {
- function __construct() {
+ public function __construct() {
parent::__construct( 'UserOptionStats' );
}
@@ -21,6 +21,7 @@
if ( !class_exists( 'PHPlot' ) ) {
$this->getOutput()->addWikiMsg( 'uos-warn' );
+
return;
}
@@ -53,6 +54,7 @@
}
$this->getOutput()->addWikiMsg(
'uos-choose-hidden', $lang->commaList( $hiddenopts ) );
}
+
return;
}
@@ -158,6 +160,7 @@
if ( isset( $wgHiddenPrefs ) && is_array( $wgHiddenPrefs ) ) {
return $wgHiddenPrefs;
}
+
return array();
}
diff --git a/UserOptionStats.i18n.php b/UserOptionStats.i18n.php
deleted file mode 100644
index a1136d7..0000000
--- a/UserOptionStats.i18n.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * This is a backwards-compatibility shim, generated by:
- *
https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php
- *
- * Beginning with MediaWiki 1.23, translation strings are stored in json files,
- * and the EXTENSION.i18n.php file only exists to provide compatibility with
- * older releases of MediaWiki. For more information about this migration, see:
- * https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format
- *
- * This shim maintains compatibility back to MediaWiki 1.17.
- */
-$messages = array();
-if ( !function_exists( 'wfJsonI18nShim47e6f9b4f4e0d9b2' ) ) {
- function wfJsonI18nShim47e6f9b4f4e0d9b2( $cache, $code, &$cachedData ) {
- $codeSequence = array_merge( array( $code ),
$cachedData['fallbackSequence'] );
- foreach ( $codeSequence as $csCode ) {
- $fileName = dirname( __FILE__ ) . "/i18n/$csCode.json";
- if ( is_readable( $fileName ) ) {
- $data = FormatJson::decode( file_get_contents(
$fileName ), true );
- foreach ( array_keys( $data ) as $key ) {
- if ( $key === '' || $key[0] === '@' ) {
- unset( $data[$key] );
- }
- }
- $cachedData['messages'] = array_merge( $data,
$cachedData['messages'] );
- }
-
- $cachedData['deps'][] = new FileDependency( $fileName );
- }
- return true;
- }
-
- $GLOBALS['wgHooks']['LocalisationCacheRecache'][] =
'wfJsonI18nShim47e6f9b4f4e0d9b2';
-}
diff --git a/UserOptionStats.php b/UserOptionStats.php
index 285bb92..a4c4c15 100644
--- a/UserOptionStats.php
+++ b/UserOptionStats.php
@@ -1,5 +1,7 @@
<?php
-if ( !defined( 'MEDIAWIKI' ) ) die();
+if ( !defined( 'MEDIAWIKI' ) ) {
+ die();
+}
/**
* An useless extension for making pie charts of user options usage.
@@ -24,17 +26,16 @@
*/
$wgExtensionCredits['specialpage'][] = array(
- 'path' => __FILE__,
- 'name' => 'User Option Statistics',
- 'version' => '1.3.0',
- 'author' => 'Niklas Laxström',
+ 'path' => __FILE__,
+ 'name' => 'User Option Statistics',
+ 'version' => '1.4.0',
+ 'author' => 'Niklas Laxström',
'descriptionmsg' => 'useroptionstats-desc',
- 'url' =>
'https://www.mediawiki.org/wiki/Extension:UserOptionStats',
+ 'url' => 'https://www.mediawiki.org/wiki/Extension:UserOptionStats',
);
$dir = __DIR__;
$wgAutoloadClasses['SpecialUserOptionStats'] =
"$dir/SpecialUserOptionStats.php";
$wgMessagesDirs['UserOptionStats'] = __DIR__ . '/i18n';
-$wgExtensionMessagesFiles['UserOptionStats'] = "$dir/UserOptionStats.i18n.php";
$wgExtensionMessagesFiles['UserOptionStatsAlias'] =
"$dir/UserOptionStats.alias.php";
$wgSpecialPages['UserOptionStats'] = 'SpecialUserOptionStats';
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..4365e8a
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,12 @@
+{
+ "require-dev": {
+ "jakub-onderka/php-parallel-lint": "0.9",
+ "mediawiki/mediawiki-codesniffer": "0.4.0"
+ },
+ "scripts": {
+ "test": [
+ "parallel-lint . --exclude vendor",
+ "phpcs -p -s"
+ ]
+ }
+}
diff --git a/i18n/en.json b/i18n/en.json
index e4699e1..da8ca40 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -1,16 +1,16 @@
{
- "@metadata": {
- "authors": [
- "Nike",
- "SPQRobin"
- ]
- },
- "useroptionstats": "User option statistics",
- "useroptionstats-desc": "[[Special:UserOptionStats|Special page]] for
reporting on MediaWiki user option usage",
- "uos-warn": "PHPlot is not installed!",
- "uos-choose": "Choose one of the following user options: $1",
- "uos-choose-hidden": "Choose one of the following hidden user options: $1",
- "uos-unknown": "*Default",
- "uos-other": "*Other",
- "uos-title": "Distribution of values of user option $1"
+ "@metadata": {
+ "authors": [
+ "Nike",
+ "SPQRobin"
+ ]
+ },
+ "useroptionstats": "User option statistics",
+ "useroptionstats-desc": "[[Special:UserOptionStats|Special page]] for
reporting on MediaWiki user option usage",
+ "uos-warn": "PHPlot is not installed!",
+ "uos-choose": "Choose one of the following user options: $1",
+ "uos-choose-hidden": "Choose one of the following hidden user options:
$1",
+ "uos-unknown": "*Default",
+ "uos-other": "*Other",
+ "uos-title": "Distribution of values of user option $1"
}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..76e8a82
--- /dev/null
+++ b/package.json
@@ -0,0 +1,12 @@
+{
+ "private": true,
+ "scripts": {
+ "test": "grunt test"
+ },
+ "devDependencies": {
+ "grunt": "0.4.5",
+ "grunt-cli": "0.1.13",
+ "grunt-banana-checker": "0.2.2",
+ "grunt-jsonlint": "1.0.4"
+ }
+}
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..d81a292
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<ruleset>
+ <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
+ <file>.</file>
+ <arg name="extensions" value="php,php5,inc"/>
+ <arg name="encoding" value="utf8"/>
+ <exclude-pattern>vendor</exclude-pattern>
+</ruleset>
--
To view, visit https://gerrit.wikimedia.org/r/243162
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I06cedc55c0d64950d94225cc12c1a57b961d06c0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UserOptionStats
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits