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 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/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 @@
<?php
+
/**
* Special page
*
@@ -9,7 +10,6 @@
* @copyright Copyright © 2012-2013 Lost in Translations Inc.
* @license GPL-2.0+
*/
-
class SpecialInviteSignup extends SpecialPage {
protected $groups;
protected $store;
@@ -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' ), "$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(
$invite['used'], $user ) : '' ) .
+ Html::element( 'td',
+ array( 'data-sort-value' =>
$invite['used'] ),
+ $invite['used'] ?
$lang->userTimeAndDate( $invite['used'], $user ) : ''
+ ) .
Html::element( 'td', null, $groups ) .
- Html::rawElement( 'td', null, $invite['used'] ?
'' : $this->getDeleteButton( $invite['hash'] ) ) .
+ Html::rawElement( 'td',
+ null,
+ $invite['used'] ? '' :
$this->getDeleteButton( $invite['hash'] )
+ ) .
Html::closeElement( 'tr' )
);
}
@@ -125,6 +135,7 @@
$form .= Html::hidden( 'do', 'delete' );
$form .= Xml::submitButton( $this->msg( 'is-delete' )->text() );
$form .= Html::closeElement( 'form' );
+
return $form;
}
@@ -145,7 +156,11 @@
$groupChecks = array();
foreach ( $this->groups as $group ) {
- $groupChecks[] = Xml::checkLabel( User::getGroupMember(
$group ), "group-$group", "group-$group" );
+ $groupChecks[] = Xml::checkLabel(
+ User::getGroupMember( $group ),
+ "group-$group",
+ "group-$group"
+ );
}
$row =
@@ -159,13 +174,16 @@
Html::rawElement( 'td', null, $add ) .
Html::closeElement( 'form' ) .
Html::closeElement( 'tr' );
+
return $row;
}
public static function sendInviteEmail( User $inviter, $email, $hash ) {
global $wgPasswordSender;
- $url = Title::newFromText( 'Special:Userlogin/signup'
)->getCanonicalUrl( array( 'invite' => $hash, 'returnto' => 'Special:Dashboard'
) );
+ $url = Title::newFromText( 'Special:Userlogin/signup'
)->getCanonicalUrl(
+ array( 'invite' => $hash, 'returnto' =>
'Special:Dashboard' )
+ );
$subj = wfMessage( 'is-emailsubj' )->inContentLanguage();
$body = wfMessage( 'is-emailbody' )
@@ -178,7 +196,7 @@
'to' => $emailTo,
'from' => $emailFrom,
'replyto' => $emailFrom,
- 'body' => $body->text(),
+ 'body' => $body->text(),
'subj' => $subj->text(),
);
$job = new EmaillingJob( Title::newMainPage(), $params );
diff --git a/composer.json b/composer.json
index b5d3999..4365e8a 100644
--- a/composer.json
+++ b/composer.json
@@ -1,24 +1,12 @@
{
- "name": "mediawiki/invite-signup",
- "type": "mediawiki-extension",
- "description": "Invite users to sign up",
- "keywords": [
- "MediaWiki"
- ],
- "homepage": "https://www.mediawiki.org/wiki/Extension:InviteSignup",
- "license": "GPL-2.0+",
- "authors": [
- {
- "name": "Niklas Laxström",
- "email": "[email protected]",
- "role": "Developer"
- }
- ],
- "support": {
- "issues": "https://phabricator.wikimedia.org/"
+ "require-dev": {
+ "jakub-onderka/php-parallel-lint": "0.9",
+ "mediawiki/mediawiki-codesniffer": "0.4.0"
},
- "require": {
- "php": ">=5.3.0",
- "composer/installers": ">=1.0.1"
+ "scripts": {
+ "test": [
+ "parallel-lint . --exclude vendor",
+ "phpcs -p -s"
+ ]
}
}
diff --git a/i18n/en.json b/i18n/en.json
index 69ece62..de27600 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -1,21 +1,21 @@
{
- "@metadata": {
- "authors": [
- "Niklas Laxström"
- ]
- },
- "invitesignup": "Invite people to this wiki",
- "is-desc": "Send email invites",
- "is-tableth-date": "Date",
- "is-tableth-email": "Email",
- "is-tableth-inviter": "Inviter",
- "is-tableth-signup": "Signed up",
- "is-tableth-groups": "Groups",
- "is-add": "Add",
- "is-delete": "Delete",
- "is-invalidemail": "<b>$1</b> is not a valid email address.",
- "is-emailsubj": "You are invited to join {{SITENAME}}",
- "is-emailbody": "Hello,\n\n{{GENDER:$1|$1}} has invited you to sign up to
{{SITENAME}}.\nYou can sign up at $2",
- "right-invitesignup": "Invite users to sign up",
- "action-invitesignup": "invite users to sign up to this site"
+ "@metadata": {
+ "authors": [
+ "Niklas Laxström"
+ ]
+ },
+ "invitesignup": "Invite people to this wiki",
+ "is-desc": "Send email invites",
+ "is-tableth-date": "Date",
+ "is-tableth-email": "Email",
+ "is-tableth-inviter": "Inviter",
+ "is-tableth-signup": "Signed up",
+ "is-tableth-groups": "Groups",
+ "is-add": "Add",
+ "is-delete": "Delete",
+ "is-invalidemail": "<b>$1</b> is not a valid email address.",
+ "is-emailsubj": "You are invited to join {{SITENAME}}",
+ "is-emailbody": "Hello,\n\n{{GENDER:$1|$1}} has invited you to sign up
to {{SITENAME}}.\nYou can sign up at $2",
+ "right-invitesignup": "Invite users to sign up",
+ "action-invitesignup": "invite users to sign up to this site"
}
\ No newline at end of file
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/243110
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I31124bf9fe7602e57141938b414b9d78ee8dd2ac
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/InviteSignup
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits