/**
  * @param array $args
  * @param string $key
  */
 protected function applyArrayArgs(array $args, $key)
 {
     if (!isset($args[$key])) {
         return;
     }
     $arg = $args[$key];
     $setter = 'set' . ucfirst($key);
     if (is_array($arg)) {
         $this->mailService->getMessage()->{$setter}(array_keys($arg)[0], array_values($arg)[0]);
         return;
     }
     $this->mailService->getMessage()->{$setter}($arg);
 }
 /**
  * Applies the arguments provided while invoking this plugin to the MailService,
  * discarding any previous configuration
  *
  * @param array $args
  */
 protected function applyArgsToMailService(array $args)
 {
     if (isset($args['body'])) {
         $body = $args['body'];
         if (is_string($body)) {
             $this->mailService->setBody($body);
         } else {
             $this->mailService->setTemplate($body);
         }
     }
     if (isset($args['subject'])) {
         $this->mailService->setSubject($args['subject']);
     }
     if (isset($args['to'])) {
         $this->mailService->getMessage()->setTo($args['to']);
     }
     if (isset($args['from'])) {
         $from = $args['from'];
         if (is_array($from)) {
             $fromAddress = array_keys($from);
             $fromName = array_values($from);
             $this->mailService->getMessage()->setFrom($fromAddress[0], $fromName[0]);
         } else {
             $this->mailService->getMessage()->setFrom($from);
         }
     }
     if (isset($args['cc'])) {
         $this->mailService->getMessage()->setCc($args['cc']);
     }
     if (isset($args['bcc'])) {
         $this->mailService->getMessage()->setBcc($args['bcc']);
     }
     if (isset($args['attachments'])) {
         $this->mailService->setAttachments($args['attachments']);
     }
 }
 public function testBodyIsValidAsViewModel()
 {
     $result = $this->plugin->__invoke(new ViewModel());
     $this->assertInstanceOf('AcMailer\\Result\\ResultInterface', $result);
     $this->assertEquals('ViewModel body', $this->service->getMessage()->getBody());
 }