public function testNonScalarReplaceValuesAreNotInterpolated()
 {
     $variables = [new Esendex_Sms_Model_Variable('totalsales', 'total_sales'), new Esendex_Sms_Model_Variable('numorders', 'number_of_orders')];
     $container = new Varien_Object();
     $container->setData(['total_sales' => new stdClass(), 'number_of_orders' => 100]);
     $msg = 'Cannot replace placeholder with a non-scalar value (Eg, String, Integer). Got: "stdClass"';
     $this->logger->expects($this->once())->method('error')->with($msg);
     $message = 'Your store has made $TOTALSALES$ through $NUMORDERS$ orders';
     $result = $this->interpolator->interpolate($message, $container, $variables);
     $expected = 'Your store has made through 100 orders';
     $this->assertSame($expected, $result);
 }
 /**
  * Get the message for each trigger
  * Do variable replacing and post-processing
  *
  * @param Esendex_Sms_Model_Resource_Trigger_Collection $triggers
  * @param Esendex_Sms_Model_EventProcessor_Interface    $eventProcessor
  *
  * @return array
  */
 protected function processTriggers(Esendex_Sms_Model_Resource_Trigger_Collection $triggers, Esendex_Sms_Model_EventProcessor_Interface $eventProcessor)
 {
     $messages = array();
     foreach ($triggers as $trigger) {
         if (!$eventProcessor->shouldSend($trigger)) {
             continue;
         }
         $recipients = $eventProcessor->getRecipient($trigger);
         $sender = $trigger->getData('sender');
         //replace the placeholders with actual variables
         $messageBody = $this->messageInterpolator->interpolate($trigger->getMessageTemplate(), $eventProcessor->getVariableContainer($trigger), $eventProcessor->getVariables());
         $messageBody = $eventProcessor->postProcess($messageBody);
         $message = new Esendex_Sms_Model_Message($messageBody, $sender, $recipients);
         $messages[] = $message;
     }
     return $messages;
 }