/**
  * testing the is_messenger_active() method
  *
  * @since 4.4.1
  */
 public function test_is_messenger_active()
 {
     //test messenger that should be active
     EE_Registry::instance()->load_helper('MSG_Template');
     $this->assertTrue(EEH_MSG_Template::is_messenger_active('email'));
     //test messenger that should NOT be active
     $this->assertFalse(EEH_MSG_Template::is_messenger_active('some_random_messenger'));
 }
 /**
  * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send trigger
  *
  * @since   4.3.0
  *
  * @param 	string 	$registration_message_trigger_url
  * @param 	EE_Registration $registration
  * @param string 	$messenger
  * @param string 	$message_type
  * @return 	string
  */
 public static function registration_message_trigger_url($registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice')
 {
     EE_Registry::instance()->load_helper('MSG_Template');
     // whitelist $messenger
     switch ($messenger) {
         case 'pdf':
             $sending_messenger = 'pdf';
             $generating_messenger = 'html';
             break;
         case 'html':
         default:
             $sending_messenger = 'html';
             $generating_messenger = 'html';
             break;
     }
     // whitelist $message_type
     switch ($message_type) {
         case 'receipt':
             $message_type = 'receipt';
             break;
         case 'invoice':
         default:
             $message_type = 'invoice';
             break;
     }
     // verify that both the messenger AND the message type are active
     if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) {
         //need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?)
         $template_query_params = array('MTP_is_active' => TRUE, 'MTP_messenger' => $generating_messenger, 'MTP_message_type' => $message_type, 'Event.EVT_ID' => $registration->event_ID());
         //get the message template group.
         $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
         //if we don't have an EE_Message_Template_Group then return
         if (!$msg_template_group instanceof EE_Message_Template_Group) {
             // remove EVT_ID from query params so that global templates get picked up
             unset($template_query_params['Event.EVT_ID']);
             //get global template as the fallback
             $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
         }
         //if we don't have an EE_Message_Template_Group then return
         if (!$msg_template_group instanceof EE_Message_Template_Group) {
             return '';
         }
         // generate the URL
         $registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger($sending_messenger, $generating_messenger, 'purchaser', $message_type, $registration, $msg_template_group->ID(), $registration->transaction_ID());
     }
     return $registration_message_trigger_url;
 }