Addshore has uploaded a new change for review.

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

Change subject: PHPCS everywhere
......................................................................

PHPCS everywhere

Change-Id: I12a30bca43fcfdcf334f896630f2c7c66655b568
---
M Newsletter.alias.php
M Newsletter.hooks.php
M includes/ApiNewsletter.php
M includes/ApiNewsletterManage.php
M includes/EchoNewsletterFormatter.php
M includes/SpecialNewsletterCreate.php
M includes/SpecialNewsletterManage.php
M includes/SpecialNewsletters.php
M tests/ApiNewsletterTest.php
9 files changed, 242 insertions(+), 180 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Newsletter 
refs/changes/20/234120/1

diff --git a/Newsletter.alias.php b/Newsletter.alias.php
index b594417..a0e52c9 100644
--- a/Newsletter.alias.php
+++ b/Newsletter.alias.php
@@ -10,7 +10,7 @@
 
 /** English */
 $specialPageAliases['en'] = array(
-       'NewsletterCreate' => array( 'CreateNewsletter'),
-       'NewsletterManage' => array( 'ManageNewsletter'),
-       'Newsletters' => array( 'Newsletters'),
-);
\ No newline at end of file
+       'NewsletterCreate' => array( 'CreateNewsletter' ),
+       'NewsletterManage' => array( 'ManageNewsletter' ),
+       'Newsletters' => array( 'Newsletters' ),
+);
diff --git a/Newsletter.hooks.php b/Newsletter.hooks.php
index 5834ebc..3d12f57 100755
--- a/Newsletter.hooks.php
+++ b/Newsletter.hooks.php
@@ -1,8 +1,10 @@
 <?php
+
 /**
  * Class to add Hooks used by Newsletter.
  */
 class NewsletterHooks {
+
        /**
         * Function to be called before EchoEvent
         *
@@ -10,7 +12,7 @@
         * @param array $notificationCategories Echo notification categories
         * @return bool
         */
-       public static function onBeforeCreateEchoEvent( &$notifications, 
&$notificationCategories  ) {
+       public static function onBeforeCreateEchoEvent( &$notifications, 
&$notificationCategories ) {
                $notificationCategories['newsletter'] = array(
                        'priority' => 3,
                        'tooltip' => 'echo-pref-tooltip-newsletter',
@@ -79,4 +81,5 @@
 
                return true;
        }
+
 }
diff --git a/includes/ApiNewsletter.php b/includes/ApiNewsletter.php
index f93d8de..4befbf8 100644
--- a/includes/ApiNewsletter.php
+++ b/includes/ApiNewsletter.php
@@ -1,12 +1,13 @@
 <?php
 
 class ApiNewsletter extends ApiBase {
+
        public function execute() {
                $dbw = wfGetDB( DB_MASTER );
                if ( $this->getMain()->getVal( 'todo' ) === 'subscribe' ) {
                        $rowData = array(
                                'newsletter_id' => $this->getMain()->getVal( 
'newsletterId' ),
-                               'subscriber_id' => $this->getUser()->getId()
+                               'subscriber_id' => $this->getUser()->getId(),
                        );
                        $dbw->insert( 'nl_subscriptions', $rowData, __METHOD__ 
);
                }
@@ -21,15 +22,19 @@
        }
 
        public function getAllowedParams() {
-               return array_merge( parent::getAllowedParams(), array(
-                       'newsletterId' => array (
-                               ApiBase::PARAM_TYPE => 'string',
-                               ApiBase::PARAM_REQUIRED => true
-                       ),
-                       'todo' => array (
-                               ApiBase::PARAM_TYPE => 'string',
-                               ApiBase::PARAM_REQUIRED => true
+               return array_merge(
+                       parent::getAllowedParams(),
+                       array(
+                               'newsletterId' => array(
+                                       ApiBase::PARAM_TYPE => 'string',
+                                       ApiBase::PARAM_REQUIRED => true,
+                               ),
+                               'todo' => array(
+                                       ApiBase::PARAM_TYPE => 'string',
+                                       ApiBase::PARAM_REQUIRED => true,
+                               ),
                        )
-               ) );
+               );
        }
-}
\ No newline at end of file
+
+}
diff --git a/includes/ApiNewsletterManage.php b/includes/ApiNewsletterManage.php
index 56a4355..aa23f69 100644
--- a/includes/ApiNewsletterManage.php
+++ b/includes/ApiNewsletterManage.php
@@ -1,35 +1,39 @@
 <?php
+
 /**
  * API to manage newsletters
- *
  */
 class ApiNewsletterManage extends ApiBase {
+
        public function execute() {
                $dbw = wfGetDB( DB_MASTER );
                if ( $this->getMain()->getVal( 'todo' ) === 'removepublisher' ) 
{
                        $rowData = array(
                                'newsletter_id' => $this->getMain()->getVal( 
'newsletterId' ),
-                               'publisher_id' => $this->getMain()->getVal( 
'publisher' )
+                               'publisher_id' => $this->getMain()->getVal( 
'publisher' ),
                        );
                        $dbw->delete( 'nl_publishers', $rowData, __METHOD__ );
                }
-
        }
 
        public function getAllowedParams() {
-               return array_merge( parent::getAllowedParams(), array(
-                       'newsletterId' => array (
-                               ApiBase::PARAM_TYPE => 'string',
-                               ApiBase::PARAM_REQUIRED => true
-                       ),
-                       'todo' => array (
-                               ApiBase::PARAM_TYPE => 'string',
-                               ApiBase::PARAM_REQUIRED => true
-                       ),
-                       'publisher' => array(
-                               ApiBase::PARAM_TYPE => 'string',
-                               ApiBase::PARAM_REQUIRED => true
+               return array_merge(
+                       parent::getAllowedParams(),
+                       array(
+                               'newsletterId' => array(
+                                       ApiBase::PARAM_TYPE => 'string',
+                                       ApiBase::PARAM_REQUIRED => true,
+                               ),
+                               'todo' => array(
+                                       ApiBase::PARAM_TYPE => 'string',
+                                       ApiBase::PARAM_REQUIRED => true,
+                               ),
+                               'publisher' => array(
+                                       ApiBase::PARAM_TYPE => 'string',
+                                       ApiBase::PARAM_REQUIRED => true,
+                               ),
                        )
-               ) );
+               );
        }
-}
\ No newline at end of file
+
+}
diff --git a/includes/EchoNewsletterFormatter.php 
b/includes/EchoNewsletterFormatter.php
index 325f583..022abb1 100644
--- a/includes/EchoNewsletterFormatter.php
+++ b/includes/EchoNewsletterFormatter.php
@@ -1,6 +1,7 @@
 <?php
 
 class EchoNewsletterFormatter extends EchoBasicFormatter {
+
        /**
         * @param EchoEvent $event
         * @param string $param
@@ -10,7 +11,7 @@
        protected function processParam( $event, $param, $message, $user ) {
                if ( $param === 'newsletter' ) {
                        $message->params( $event->getExtraParam( 'newsletter' ) 
);
-               } else if ( $param === 'title' ) {
+               } elseif ( $param === 'title' ) {
                        $message->params( $event->getExtraParam( 
'issuePageTitle' ) );
                } else {
                        parent::processParam( $event, $param, $message, $user );
@@ -18,18 +19,26 @@
        }
 
        /**
-       * Set target URL for primary link of notification
-       *
-       * @param EchoEvent $event
-       * @param User $user The user receiving the notification
-       * @param string $destination The destination type for the link
-       * @return array including target URL
-       */
+        * Set target URL for primary link of notification
+        *
+        * @param EchoEvent $event
+        * @param User $user The user receiving the notification
+        * @param string $destination The destination type for the link
+        *
+        * @return array including target URL
+        */
        protected function getLinkParams( $event, $user, $destination ) {
                if ( $destination === 'new-issue' ) {
-                       return array( Title::makeTitle( $event->getExtraParam( 
'issuePageNamespace' ), $event->getExtraParam( 'issuePageTitle' ) ), array() );
+                       return array(
+                               Title::makeTitle(
+                                       $event->getExtraParam( 
'issuePageNamespace' ),
+                                       $event->getExtraParam( 'issuePageTitle' 
)
+                               ),
+                               array(),
+                       );
                } else {
                        return parent::getLinkParams( $event, $user, 
$destination );
                }
        }
-}
\ No newline at end of file
+
+}
diff --git a/includes/SpecialNewsletterCreate.php 
b/includes/SpecialNewsletterCreate.php
index b89adc1..53fdce9 100644
--- a/includes/SpecialNewsletterCreate.php
+++ b/includes/SpecialNewsletterCreate.php
@@ -1,10 +1,12 @@
 <?php
+
 /**
  * Special page for creating newsletters
  *
  * @todo Make this extend FormSpecialPage
  */
 class SpecialNewsletterCreate extends SpecialPage {
+
        public function __construct() {
                parent::__construct( 'NewsletterCreate' );
        }
@@ -16,7 +18,11 @@
                $createNewsletterArray = $this->getCreateFormFields();
 
                # Create HTML forms
-               $createNewsletterForm = new HTMLForm( $createNewsletterArray, 
$this->getContext(), 'createnewsletterform' );
+               $createNewsletterForm = new HTMLForm(
+                       $createNewsletterArray,
+                       $this->getContext(),
+                       'createnewsletterform'
+               );
                $createNewsletterForm->setSubmitTextMsg( 
'newsletter-create-submit' );
                $createNewsletterForm->setSubmitCallback( array( $this, 
'onSubmitNewsletter' ) );
                $createNewsletterForm->setWrapperLegendMsg( 
'newsletter-create-section' );
@@ -56,15 +62,15 @@
                                'options' => array(
                                        'weekly' => $this->msg( 
'newsletter-option-weekly' ),
                                        'monthly' => $this->msg( 
'newsletter-option-monthly' ),
-                                       'quarterly' => $this->msg( 
'newsletter-option-quarterly' )
+                                       'quarterly' => $this->msg( 
'newsletter-option-quarterly' ),
                                ),
                                'size' => 18, # size of 'other' field
-                               'maxlength' => 50
+                               'maxlength' => 50,
                        ),
                        'publisher' => array(
                                'type' => 'hidden',
-                               'default' => $this->getUser()->getId()
-                       )
+                               'default' => $this->getUser()->getId(),
+                       ),
                );
        }
 
@@ -73,6 +79,7 @@
         * form for creating newsletters
         *
         * @param array $formData The data entered by user in the form
+        *
         * @return bool|array true on success, array on error
         */
        public function onSubmitNewsletter( array $formData ) {
@@ -82,8 +89,13 @@
                } else {
                        return array( 'newsletter-create-mainpage-error' );
                }
-               if ( isset( $formData['name'] ) && isset( 
$formData['description'] ) && ( $pageId !== 0 ) &&
-                       isset( $formData['mainpage'] ) && isset( 
$formData['frequency'] ) && isset( $formData['publisher'] ) ) {
+               if ( isset( $formData['name'] ) &&
+                       isset( $formData['description'] ) &&
+                       ( $pageId !== 0 ) &&
+                       isset( $formData['mainpage'] ) &&
+                       isset( $formData['frequency'] ) &&
+                       isset( $formData['publisher'] )
+               ) {
                        // inserting into database
                        $dbw = wfGetDB( DB_MASTER );
                        $rowData = array(
@@ -91,12 +103,13 @@
                                'nl_desc' => $formData['description'],
                                'nl_main_page_id' => $pageId,
                                'nl_frequency' => $formData['frequency'],
-                               'nl_owner_id' => $formData['publisher']
+                               'nl_owner_id' => $formData['publisher'],
                        );
 
                        try {
                                $dbw->insert( 'nl_newsletters', $rowData, 
__METHOD__ );
-                       } catch ( DBQueryError $e ) {
+                       }
+                       catch ( DBQueryError $e ) {
                                return array( 'newsletter-exist-error' );
                        }
                        $this->getOutput()->addWikiMsg( 
'newsletter-create-confirmation' );
@@ -106,7 +119,7 @@
                                'nl_newsletters',
                                array( 'nl_id' ),
                                array(
-                                       'nl_name' => $formData['name']
+                                       'nl_name' => $formData['name'],
                                ),
                                __METHOD__
                        );
@@ -118,7 +131,7 @@
 
                        $pubRowData = array(
                                'newsletter_id' => $newsletterId,
-                               'publisher_id' => $formData['publisher']
+                               'publisher_id' => $formData['publisher'],
                        );
                        $dbw->insert( 'nl_publishers', $pubRowData, __METHOD__ 
);
 
@@ -127,4 +140,5 @@
 
                return array( 'newsletter-mainpage-not-found-error' );
        }
+
 }
diff --git a/includes/SpecialNewsletterManage.php 
b/includes/SpecialNewsletterManage.php
index 07c44a3..ac9dda8 100644
--- a/includes/SpecialNewsletterManage.php
+++ b/includes/SpecialNewsletterManage.php
@@ -1,17 +1,18 @@
 <?php
+
 /**
  * Special page for announcing issues and managing newsletters
- *
  */
 class SpecialNewsletterManage extends SpecialPage {
-       static $fields = array(
+
+       public static $fields = array(
                'newsletter_id' => 'name',
                'publisher_id' => 'publisher',
                'permissions' => 'permissions',
-               'action' => 'action'
+               'action' => 'action',
        );
 
-       function __construct() {
+       public function __construct() {
                parent::__construct( 'NewsletterManage' );
        }
 
@@ -24,7 +25,11 @@
                $announceIssueArray = $this->getAnnounceFormFields();
 
                # Create HTML forms
-               $announceIssueForm = new HTMLForm( $announceIssueArray, 
$this->getContext(), 'newsletter-announceissueform' );
+               $announceIssueForm = new HTMLForm(
+                       $announceIssueArray,
+                       $this->getContext(),
+                       'newsletter-announceissueform'
+               );
                $announceIssueForm->setSubmitCallback( array( $this, 
'onSubmitIssue' ) );
 
                $table = new NewsletterManageTable();
@@ -113,7 +118,7 @@
                        ),
                        'publisher' => array(
                                'type' => 'hidden',
-                               'default' => $this->getUser()->getId()
+                               'default' => $this->getUser()->getId(),
                        ),
                        'newsletter-name' => array(
                                'type' => 'select',
@@ -125,7 +130,7 @@
                                'section' => 'addpublisher-section',
                                'type' => 'text',
                                'label-message' => 
'newsletter-publisher-username',
-                       )
+                       ),
                );
        }
 
@@ -134,6 +139,7 @@
         * form for announcing issues
         *
         * @param array $formData The data entered by user in the form
+        *
         * @return bool|array true on success, array on error
         */
        public function onSubmitIssue( $formData ) {
@@ -159,7 +165,7 @@
                                        'issue_id' => $issueCount + 1,
                                        'issue_page_id' => $pageId,
                                        'issue_newsletter_id' => $newsletterId,
-                                       'issue_publisher_id' => 
$formData['publisher']
+                                       'issue_publisher_id' => 
$formData['publisher'],
                                );
                                $dbw->insert( 'nl_issues', $rowData, __METHOD__ 
);
                                $this->getOutput()->addWikiMsg( 
'newsletter-issue-announce-confirmation' );
@@ -177,15 +183,17 @@
                                        $newsletterName = $row->nl_name;
                                }
                                if ( class_exists( 'EchoEvent' ) ) {
-                                       EchoEvent::create( array(
-                                               'type' => 
'subscribe-newsletter',
-                                               'extra' => array(
-                                                       'newsletter' => 
$newsletterName,
-                                                       'newsletterId' => 
$newsletterId,
-                                                       'issuePageTitle' => 
$formData['issue-page'],
-                                                       'issuePageNamespace' => 
$pageNamepace
-                                               ),
-                                       ) );
+                                       EchoEvent::create(
+                                               array(
+                                                       'type' => 
'subscribe-newsletter',
+                                                       'extra' => array(
+                                                               'newsletter' => 
$newsletterName,
+                                                               'newsletterId' 
=> $newsletterId,
+                                                               
'issuePageTitle' => $formData['issue-page'],
+                                                               
'issuePageNamespace' => $pageNamepace,
+                                                       ),
+                                               )
+                                       );
                                }
 
                                return true;
@@ -201,14 +209,15 @@
                                $dbww = wfGetDB( DB_MASTER );
                                $rowData = array(
                                        'newsletter_id' => $pubNewsletterId,
-                                       'publisher_id' => $user->getId()
+                                       'publisher_id' => $user->getId(),
                                );
                                try {
                                        $dbww->insert( 'nl_publishers', 
$rowData, __METHOD__ );
                                        $this->getOutput()->addWikiMsg( 
'newsletter-new-publisher-confirmation' );
 
                                        return true;
-                               } catch ( DBQueryError $e ) {
+                               }
+                               catch ( DBQueryError $e ) {
                                        return array( 
'newsletter-invalid-username-error' );
                                }
                        } else {
@@ -223,9 +232,10 @@
 }
 
 class NewsletterManageTable extends TablePager {
-       static $newsletterOwners = array();
 
-       function getFieldNames() {
+       public static $newsletterOwners = array();
+
+       public function getFieldNames() {
                $header = null;
                if ( is_null( $header ) ) {
                        $header = array();
@@ -238,13 +248,13 @@
 
        }
 
-       function getQueryInfo() {
+       public function getQueryInfo() {
                $info = array(
                        'tables' => array( 'nl_publishers' ),
                        'fields' => array(
                                'newsletter_id',
-                               'publisher_id'
-                       )
+                               'publisher_id',
+                       ),
                );
 
                // get user ids of all newsletter owners
@@ -263,85 +273,89 @@
                return $info;
        }
 
-       function formatValue( $field, $value ) {
+       public function formatValue( $field, $value ) {
                static $previous;
 
-               switch( $field ) {
+               switch ( $field ) {
                        case 'newsletter_id':
-                                       if ( $previous === $value ) {
+                               if ( $previous === $value ) {
 
-                                               return null;
-                                       } else {
-                                               $dbr = wfGetDB( DB_SLAVE );
-                                               $res = $dbr->select(
-                                                       'nl_newsletters',
-                                                       array( 'nl_name' ),
-                                                       array( 'nl_id' => 
$value ),
-                                                       __METHOD__,
-                                                       array()
-                                               );
-                                               $newsletterName = null;
-                                               foreach ( $res as $row ) {
-                                                       $newsletterName = 
$row->nl_name;
-                                               }
-                                               $previous = $value;
-
-                                               return $newsletterName;
+                                       return null;
+                               } else {
+                                       $dbr = wfGetDB( DB_SLAVE );
+                                       $res = $dbr->select(
+                                               'nl_newsletters',
+                                               array( 'nl_name' ),
+                                               array( 'nl_id' => $value ),
+                                               __METHOD__,
+                                               array()
+                                       );
+                                       $newsletterName = null;
+                                       foreach ( $res as $row ) {
+                                               $newsletterName = $row->nl_name;
                                        }
-                       case 'publisher_id' :
-                                       $user = User::newFromId( $value );
+                                       $previous = $value;
 
-                                       return $user->getName();
+                                       return $newsletterName;
+                               }
+                       case 'publisher_id' :
+                               $user = User::newFromId( $value );
+
+                               return $user->getName();
                        case 'permissions' :
-                                       $radioOwner = HTML::element(
+                               $radioOwner = HTML::element(
                                                'input',
                                                array(
                                                        'type' => 'checkbox',
                                                        'disabled' => 'true',
                                                        'id' => 
'newslettermanage',
                                                        'checked' => 
self::$newsletterOwners[$this->mCurrentRow->newsletter_id]
-                                                               === 
$this->mCurrentRow->publisher_id ? true : false,                                
            )
+                                                       === 
$this->mCurrentRow->publisher_id ? true : false,
+                                               )
                                        ) . $this->msg( 
'newsletter-owner-radiobutton-label' );
 
-                                       $radioPublisher = HTML::element(
+                               $radioPublisher = HTML::element(
                                                'input',
                                                array(
                                                        'type' => 'checkbox',
                                                        'disabled' => 'true',
                                                        'id' => 
'newslettermanage',
                                                        'checked' => 
self::$newsletterOwners[$this->mCurrentRow->newsletter_id]
-                                                               === 
$this->mCurrentRow->publisher_id ? false : true,                                
            )
+                                                       === 
$this->mCurrentRow->publisher_id ? false : true,
+                                               )
                                        ) . $this->msg( 
'newsletter-publisher-radiobutton-label' );
 
-                                       return $radioOwner . $radioPublisher;
+                               return $radioOwner . $radioPublisher;
                        case 'action' :
-                                       $remButton = HTML::element(
-                                               'input',
-                                               array(
-                                                       'type' => 'button',
-                                                       'value' => 'Remove',
-                                                       'name' => $previous,
-                                                       'id' => 
$this->mCurrentRow->publisher_id
-                                               )
-                                       );
+                               $remButton = HTML::element(
+                                       'input',
+                                       array(
+                                               'type' => 'button',
+                                               'value' => 'Remove',
+                                               'name' => $previous,
+                                               'id' => 
$this->mCurrentRow->publisher_id,
+                                       )
+                               );
 
-                                       return ( 
self::$newsletterOwners[$this->mCurrentRow->newsletter_id] !== 
$this->mCurrentRow->publisher_id &&
-                                               
self::$newsletterOwners[$this->mCurrentRow->newsletter_id] == 
$this->getUser()->getId() ) ? $remButton : '';
+                               return ( 
self::$newsletterOwners[$this->mCurrentRow->newsletter_id] !==
+                                       $this->mCurrentRow->publisher_id &&
+                                       
self::$newsletterOwners[$this->mCurrentRow->newsletter_id] ==
+                                       $this->getUser()->getId() ) ? 
$remButton : '';
 
                }
        }
 
-       function getCellAttrs( $field, $value ) {
+       public function getCellAttrs( $field, $value ) {
                return array(
-                       'align' => 'center'
+                       'align' => 'center',
                );
        }
 
-       function getDefaultSort() {
+       public function getDefaultSort() {
                return 'newsletter_id';
        }
 
-       function isFieldSortable( $field ) {
+       public function isFieldSortable( $field ) {
                return false;
        }
 
diff --git a/includes/SpecialNewsletters.php b/includes/SpecialNewsletters.php
index 1bd6de0..28c8f7f 100644
--- a/includes/SpecialNewsletters.php
+++ b/includes/SpecialNewsletters.php
@@ -1,25 +1,25 @@
 <?php
+
 /**
  * Special page for subscribing/un-subscribing a newsletter
- *
  */
 class SpecialNewsletters extends SpecialPage {
 
-       static $fields = array(
+       public static $fields = array(
                'nl_name' => 'name',
                'nl_desc' => 'description',
                'subscriber_count' => 'subscriber_count',
-               'action' => 'action'
+               'action' => 'action',
        );
 
        # Array containing all newsletter ids in nl_subscriptions table
-       static $allSubscribedNewsletterId = array();
+       public static $allSubscribedNewsletterId = array();
 
        # Array containing all newsletter ids to which the logged in user is 
subscribed to
-       static $subscribedNewsletterId = array();
+       public static $subscribedNewsletterId = array();
 
        # Subscriber count
-       static $subscriberCount = array();
+       public static $subscriberCount = array();
 
        public function __construct() {
                parent::__construct( 'Newsletters' );
@@ -42,7 +42,7 @@
                }
        }
 
-       static function getSubscribedNewsletters( $id ) {
+       public static function getSubscribedNewsletters( $id ) {
                $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select(
                        'nl_subscriptions',
@@ -74,12 +74,9 @@
        }
 }
 
-
-
-
 class NewsletterTablePager extends TablePager {
 
-       function getFieldNames() {
+       public function getFieldNames() {
                static $headers = null;
                if ( is_null( $headers ) ) {
                        $headers = array();
@@ -91,21 +88,21 @@
                return $headers;
        }
 
-       function getQueryInfo() {
+       public function getQueryInfo() {
                $info = array(
                        'tables' => array( 'nl_newsletters' ),
                        'fields' => array(
                                'nl_name',
                                'nl_desc',
-                               'nl_id'
-                       )
+                               'nl_id',
+                       ),
                );
 
                return $info;
        }
 
-       function formatValue( $field, $value ) {
-               switch( $field ) {
+       public function formatValue( $field, $value ) {
+               switch ( $field ) {
                        case 'nl_name':
                                $dbr = wfGetDB( DB_SLAVE );
                                $res = $dbr->select(
@@ -123,53 +120,63 @@
                                $url = $mainPageId ? Title::newFromID( 
$mainPageId )->getFullURL() : "#";
 
                                return '<a href="' . $url . '">' . $value . 
'</a>';
-                       case 'nl_desc': return $value;
+                       case 'nl_desc':
+                               return $value;
                        case 'subscriber_count':
-                               return HTML::element( 'input',
+                               return HTML::element(
+                                       'input',
                                        array(
-                                       'type' => 'textbox',
-                                       'readonly' => 'true',
-                                       'id' => 'newsletter-' . 
$this->mCurrentRow->nl_id,
-                                       'value' => in_array( 
$this->mCurrentRow->nl_id, SpecialNewsletters::$allSubscribedNewsletterId ) ?
-                                               
SpecialNewsletters::$subscriberCount[$this->mCurrentRow->nl_id] : 0,
+                                               'type' => 'textbox',
+                                               'readonly' => 'true',
+                                               'id' => 'newsletter-' . 
$this->mCurrentRow->nl_id,
+                                               'value' => in_array(
+                                                       
$this->mCurrentRow->nl_id,
+                                                       
SpecialNewsletters::$allSubscribedNewsletterId
+                                               ) ?
+                                                       
SpecialNewsletters::$subscriberCount[$this->mCurrentRow->nl_id] : 0,
 
-                                       ) );
+                                       )
+                               );
                        case 'action' :
                                $radioSubscribe = Html::element(
-                                                       'input',
-                                                       array(
+                                               'input',
+                                               array(
                                                        'type' => 'radio',
                                                        'name' => 'nl_id-' . 
$this->mCurrentRow->nl_id,
                                                        'value' => 'subscribe',
-                                                       'checked' => in_array( 
$this->mCurrentRow->nl_id,
-                                                                       
SpecialNewsletters::$subscribedNewsletterId ) ? true : false,
-                                                       )
+                                                       'checked' => in_array(
+                                                               
$this->mCurrentRow->nl_id,
+                                                               
SpecialNewsletters::$subscribedNewsletterId
+                                                       ) ? true : false,
+                                               )
                                        ) . $this->msg( 
'newsletter-subscribe-button-label' );
                                $radioUnSubscribe = Html::element(
-                                                       'input',
-                                                       array(
+                                               'input',
+                                               array(
                                                        'type' => 'radio',
                                                        'name' => 'nl_id-' . 
$this->mCurrentRow->nl_id,
                                                        'value' => 
'unsubscribe',
-                                                       'checked' => in_array( 
$this->mCurrentRow->nl_id,
-                                                                       
SpecialNewsletters::$subscribedNewsletterId ) ? false : true,
-                                                       )
-                               ) . $this->msg( 
'newsletter-unsubscribe-button-label' );
+                                                       'checked' => in_array(
+                                                               
$this->mCurrentRow->nl_id,
+                                                               
SpecialNewsletters::$subscribedNewsletterId
+                                                       ) ? false : true,
+                                               )
+                                       ) . $this->msg( 
'newsletter-unsubscribe-button-label' );
 
                                return $radioSubscribe . $radioUnSubscribe;
                }
        }
 
-       function endQuery( $value ) {
+       public function endQuery( $value ) {
                $this->getOutput()->addWikiMsg( 
'newsletter-create-confirmation' );
        }
 
-       function getDefaultSort() {
+       public function getDefaultSort() {
                return 'nl_name';
        }
 
-       function isFieldSortable( $field ) {
+       public function isFieldSortable( $field ) {
                return false;
        }
 
-}
\ No newline at end of file
+}
diff --git a/tests/ApiNewsletterTest.php b/tests/ApiNewsletterTest.php
index 8475145..19e1be6 100644
--- a/tests/ApiNewsletterTest.php
+++ b/tests/ApiNewsletterTest.php
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * Unit test to test Api module - ApiNewsletter
  *
@@ -8,9 +9,9 @@
  * @covers ApiNewsletter
  * @author Tina Johnson
  */
-
 class ApiNewsletterTest extends ApiTestCase {
-       protected  function setUp() {
+
+       protected function setUp() {
                parent::setUp();
                $dbw = wfGetDB( DB_MASTER );
 
@@ -22,11 +23,11 @@
                        'nl_desc' => 'This is a newsletter',
                        'nl_main_page_id' => 1,
                        'nl_frequency' => 'monthly',
-                       'nl_owner_id' => $user->getId()
+                       'nl_owner_id' => $user->getId(),
                );
                $dbw->insert( 'nl_newsletters', $rowData, __METHOD__ );
                $this->tablesUsed = array( 'nl_newsletters' );
-            }
+       }
 
        protected function getNewsletterId() {
                $dbr = wfGetDB( DB_SLAVE );
@@ -34,7 +35,7 @@
                        'nl_newsletters',
                        array( 'nl_id' ),
                        array(
-                       'nl_name' => 'MyNewsletter'
+                               'nl_name' => 'MyNewsletter',
                        ),
                        __METHOD__
                );
@@ -46,19 +47,21 @@
                return $newsletterId;
        }
 
-       function testApiNewsletterForSubscribingNewsletter() {
-               $this->doApiRequest( array(
-                       'action' => 'newsletterapi',
-                       'newsletterId' => $this->getNewsletterId(),
-                       'todo' => 'subscribe'
-               ) );
+       public function testApiNewsletterForSubscribingNewsletter() {
+               $this->doApiRequest(
+                       array(
+                               'action' => 'newsletterapi',
+                               'newsletterId' => $this->getNewsletterId(),
+                               'todo' => 'subscribe',
+                       )
+               );
 
                $dbr = wfGetDB( DB_SLAVE );
                $result = $dbr->selectRowCount(
                        'nl_subscriptions',
                        array( 'subscriber_id' ),
                        array(
-                       'newsletter_id' => $this->getNewsletterId()
+                               'newsletter_id' => $this->getNewsletterId(),
                        ),
                        __METHOD__
                );
@@ -66,23 +69,26 @@
                $this->assertEquals( $result, 1 );
        }
 
-       function testApiNewsletterForUnsubscribingNewsletter() {
-               $this->doApiRequest( array(
-                       'action' => 'newsletterapi',
-                       'newsletterId' => $this->getNewsletterId(),
-                       'todo' => 'unsubscribe'
-               ) );
+       public function testApiNewsletterForUnsubscribingNewsletter() {
+               $this->doApiRequest(
+                       array(
+                               'action' => 'newsletterapi',
+                               'newsletterId' => $this->getNewsletterId(),
+                               'todo' => 'unsubscribe',
+                       )
+               );
 
                $dbr = wfGetDB( DB_SLAVE );
                $result = $dbr->selectRowCount(
                        'nl_subscriptions',
                        array( 'subscriber_id' ),
                        array(
-                       'newsletter_id' => $this->getNewsletterId()
+                               'newsletter_id' => $this->getNewsletterId(),
                        ),
                        __METHOD__
                );
 
                $this->assertEquals( $result, 0 );
        }
-}
\ No newline at end of file
+
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I12a30bca43fcfdcf334f896630f2c7c66655b568
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Newsletter
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to