[MediaWiki-commits] [Gerrit] Add tests - change (mediawiki...InviteSignup)

2015-10-05 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Add tests
..


Add tests

Fix all issues so tests pass.

Change-Id: I31124bf9fe7602e57141938b414b9d78ee8dd2ac
---
M .gitignore
A .jshintignore
A Gruntfile.js
M InviteSignup.alias.php
M InviteSignup.php
M InviteStore.php
M SpecialInviteSignup.php
M composer.json
M i18n/en.json
A package.json
A phpcs.xml
11 files changed, 112 insertions(+), 30 deletions(-)

Approvals:
  Paladox: Looks good to me, but someone else must approve
  Hashar: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/.gitignore b/.gitignore
index 98b092a..854a2d2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
-.svn
 *~
 *.kate-swp
 .*.swp
+node_modules/
+/composer.lock
+/vendor/
diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 000..3c3629e
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1 @@
+node_modules
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 000..1c93271
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,26 @@
+/*jshint node:true */
+module.exports = function ( grunt ) {
+   grunt.loadNpmTasks( 'grunt-contrib-jshint' );
+   grunt.loadNpmTasks( 'grunt-banana-checker' );
+   grunt.loadNpmTasks( 'grunt-jsonlint' );
+
+   grunt.initConfig( {
+   jshint: {
+   all: [
+   '*.js'
+   ]
+   },
+   banana: {
+   all: 'i18n/'
+   },
+   jsonlint: {
+   all: [
+   '**/*.json',
+   '!node_modules/**'
+   ]
+   }
+   } );
+
+   grunt.registerTask( 'test', [ 'jshint', 'jsonlint', 'banana' ] );
+   grunt.registerTask( 'default', 'test' );
+};
diff --git a/InviteSignup.alias.php b/InviteSignup.alias.php
index 8d16357..c0559c7 100644
--- a/InviteSignup.alias.php
+++ b/InviteSignup.alias.php
@@ -75,4 +75,4 @@
 /** Traditional Chinese (中文(繁體)‎) */
 $specialPageAliases['zh-hant'] = array(
'InviteSignup' => array( '邀請註冊' ),
-);
\ No newline at end of file
+);
diff --git a/InviteSignup.php b/InviteSignup.php
index 4323c04..4ab9f67 100644
--- a/InviteSignup.php
+++ b/InviteSignup.php
@@ -5,9 +5,11 @@
$wgMessagesDirs['InviteSignup'] = __DIR__ . '/i18n';
$wgExtensionMessagesFiles['InviteSignup'] = __DIR__ . 
'/InviteSignup.alias.php';
wfWarn(
-   'Deprecated PHP entry point used for InviteSignup extension. 
Please use wfLoadExtension instead, ' .
-   'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
+   'Deprecated PHP entry point used for InviteSignup extension. ' .
+   'Please use wfLoadExtension instead, see ' .
+   'https://www.mediawiki.org/wiki/Extension_registration for more 
details.'
);
+
return;
 } else {
die( 'This version of the InviteSignup extension requires MediaWiki 
1.25+' );
diff --git a/InviteStore.php b/InviteStore.php
index a50b92c..e231a7a 100644
--- a/InviteStore.php
+++ b/InviteStore.php
@@ -30,6 +30,7 @@
foreach ( $res as $row ) {
$invites[] = $this->rowToArray( $row );
}
+
return $invites;
}
 
@@ -50,7 +51,6 @@
return $hash;
}
 
-
public function deleteInvite( $hash ) {
$conds = array( 'is_hash' => $hash );
$this->db->delete( $this->dbTable, $conds, __METHOD__ );
@@ -60,6 +60,7 @@
$fields = array( '*' );
$conds = array( 'is_hash' => $hash );
$res = $this->db->selectRow( $this->dbTable, $fields, $conds, 
__METHOD__ );
+
return $this->rowToArray( $res );
}
 
@@ -84,6 +85,7 @@
}
$array[substr( $key, 3 )] = $value;
}
+
return $array;
}
 }
diff --git a/SpecialInviteSignup.php b/SpecialInviteSignup.php
index 38feeb0..8b576b5 100644
--- a/SpecialInviteSignup.php
+++ b/SpecialInviteSignup.php
@@ -28,6 +28,7 @@
if ( $this->store === null ) {
$this->store = new InviteStore( wfGetDB( DB_MASTER ), 
'invitesignup' );
}
+
return $this->store;
}
 
@@ -52,7 +53,10 @@
if ( trim( $email ) === '' ) {
// Silence
} elseif ( !$okay ) {
-   $out->wrapWikiMsg( Html::rawElement( 
'div', array( 'class' => 'error' ), "$1" ), array( 'is-invalidemail', $email ) 
);
+   $out->wrapWikiMsg(
+   Html::rawElement( 'div', array( 
'class' => 'error'

[MediaWiki-commits] [Gerrit] Add tests - change (mediawiki...InviteSignup)

2015-10-01 Thread Siebrand (Code Review)
Siebrand has uploaded a new change for review.

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

Change subject: Add tests
..

Add tests

Fix all issues so tests pass.

Change-Id: I31124bf9fe7602e57141938b414b9d78ee8dd2ac
---
M .gitignore
A Gruntfile.js
M InviteSignup.php
M InviteStore.php
M SpecialInviteSignup.php
M composer.json
M i18n/en.json
A package.json
A phpcs.xml
9 files changed, 102 insertions(+), 50 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/InviteSignup 
refs/changes/10/243110/1

diff --git a/.gitignore b/.gitignore
index 98b092a..854a2d2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
-.svn
 *~
 *.kate-swp
 .*.swp
+node_modules/
+/composer.lock
+/vendor/
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 000..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/InviteSignup.php b/InviteSignup.php
index 4323c04..d7ede9a 100644
--- a/InviteSignup.php
+++ b/InviteSignup.php
@@ -5,9 +5,11 @@
$wgMessagesDirs['InviteSignup'] = __DIR__ . '/i18n';
$wgExtensionMessagesFiles['InviteSignup'] = __DIR__ . 
'/InviteSignup.alias.php';
wfWarn(
-   'Deprecated PHP entry point used for InviteSignup extension. 
Please use wfLoadExtension instead, ' .
-   'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
+   'Deprecated PHP entry point used for InviteSignup extension. ' .
+   'Please use wfLoadExtension instead, see ' .
+   'https://www.mediawiki.org/wiki/Extension_registration for more 
details.'
);
+
return;
 } else {
die( 'This version of the InviteSignup extension requires MediaWiki 
1.25+' );
diff --git a/InviteStore.php b/InviteStore.php
index a50b92c..e231a7a 100644
--- a/InviteStore.php
+++ b/InviteStore.php
@@ -30,6 +30,7 @@
foreach ( $res as $row ) {
$invites[] = $this->rowToArray( $row );
}
+
return $invites;
}
 
@@ -50,7 +51,6 @@
return $hash;
}
 
-
public function deleteInvite( $hash ) {
$conds = array( 'is_hash' => $hash );
$this->db->delete( $this->dbTable, $conds, __METHOD__ );
@@ -60,6 +60,7 @@
$fields = array( '*' );
$conds = array( 'is_hash' => $hash );
$res = $this->db->selectRow( $this->dbTable, $fields, $conds, 
__METHOD__ );
+
return $this->rowToArray( $res );
}
 
@@ -84,6 +85,7 @@
}
$array[substr( $key, 3 )] = $value;
}
+
return $array;
}
 }
diff --git a/SpecialInviteSignup.php b/SpecialInviteSignup.php
index 38feeb0..24986e5 100644
--- a/SpecialInviteSignup.php
+++ b/SpecialInviteSignup.php
@@ -1,4 +1,5 @@
 store === null ) {
$this->store = new InviteStore( wfGetDB( DB_MASTER ), 
'invitesignup' );
}
+
return $this->store;
}
 
@@ -52,7 +53,10 @@
if ( trim( $email ) === '' ) {
// Silence
} elseif ( !$okay ) {
-   $out->wrapWikiMsg( Html::rawElement( 
'div', array( 'class' => 'error' ), "$1" ), array( 'is-invalidemail', $email ) 
);
+   $out->wrapWikiMsg(
+   Html::rawElement( 'div', array( 
'class' => 'error' ), "$1" ),
+   array( 'is-invalidemail', 
$email )
+   );
} else {
$groups = array();
foreach ( $this->groups as $group ) {
@@ -104,9 +108,15 @@
Html::element( 'td', $whenSort, $when ) .
Html::element( 'td', null, $email ) .
Html::element( 'td', null, User::newFromId( 
$invite['inviter'] )->getName() ) .
-   Html::element( 'td', array( 'data-sort-value' 
=> $invite['used'] ), $invite['used'] ? $lang->userTimeAndDate( 
$invi