/**
  * tests the getLanguage function.
  * NOTE: Static vars are involved here.
  * Assertions:
  * 		getLanguage with no parameters returns english (if none of the
  * previous tests set the var differently. Static vars have tricky initial
  * conditions...)
  * 		Passing getLanguage a different language than the one previously in
  * use will cause the var to reset to the explicit language. Messages should
  * be sent in the new language.
  */
 function testGetLanguage()
 {
     $messageKey = 'contributiontracking';
     $messageBG = 'Проследяване на дарението';
     $messageEN = 'Contribution tracking';
     $code = ContributionTrackingProcessor::getLanguage();
     $this->assertEquals($code, 'en', "Default language is not US (or your test has a hangover)");
     $params['language'] = 'bg';
     $code = ContributionTrackingProcessor::getLanguage($params);
     $this->assertEquals($params['language'], $code, "Returned language is not the one we just sent.");
     $message = ContributionTrackingProcessor::msg($messageKey);
     $this->assertEquals($message, $messageBG, "Returned language is not the one we just sent.");
     $params['language'] = 'en';
     $code = ContributionTrackingProcessor::getLanguage($params);
     $this->assertEquals($params['language'], $code, "Returned language is not the one we just sent.");
     $message = ContributionTrackingProcessor::msg($messageKey);
     $this->assertEquals($message, $messageEN, "Returned language is not the one we just sent.");
 }
 /**
  * Stages the relevent data that will be sent to the gateway
  * @global string $wgContributionTrackingPayPalRecurringIPN URL for paypal
  * recurring donations : Defined in ContributionTracking.php
  * @global string $wgContributionTrackingPayPalIPN URL for paypal recurring
  * donations : Defined in ContributionTracking.php
  * @param array $params Parameters to post to the gateway
  * @return array Staged array
  */
 static function stage_repost($params)
 {
     global $wgContributionTrackingPayPalRecurringIPN, $wgContributionTrackingPayPalIPN;
     //TODO: assert that gateway makes The Sense here.
     //change the posted names to match the db where necessary
     ContributionTrackingProcessor::rekey($params, 'amountGiven', 'amount_given');
     ContributionTrackingProcessor::rekey($params, 'returnto', 'return');
     //booleanize!
     ContributionTrackingProcessor::stage_checkbox($params, 'recurring_paypal');
     //poke our language function with the current parameters - this sets the static var correctly
     $params['language'] = ContributionTrackingProcessor::getLanguage($params);
     if (array_key_exists('recurring_paypal', $params) && $params['recurring_paypal']) {
         $params['notify_url'] = $wgContributionTrackingPayPalRecurringIPN;
         $params['item_name'] = ContributionTrackingProcessor::msg('contrib-tracking-item-name-recurring');
     } else {
         $params['notify_url'] = $wgContributionTrackingPayPalIPN;
         $params['item_name'] = ContributionTrackingProcessor::msg('contrib-tracking-item-name-onetime');
     }
     $repost_params = ContributionTrackingProcessor::mergeArrayDefaults($params, ContributionTrackingProcessor::getRepostDefaults(), true);
     return $repost_params;
 }