Esempio n. 1
0
 /**
  * Adds an error to the list of errors.
  *
  * @param  PHPUnit_Framework_Test $test
  * @param  Exception              $e
  * @param  float                  $time
  */
 public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
 {
     $message = "\n" . $e->getMessage();
     if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
         /** @var $e PHPUnit_Framework_ExpectationFailedException */
         //$message .= "\n" . $e->getComparisonFailure()->toString();
     }
     $name = $test->getName(false);
     $mail = new Enlight_Components_Mail();
     $mail->addTo($this->mailRecipients);
     $mail->setSubject('PHPUnit test "' . $name . '" failed.');
     $mail->setBodyText($message);
     if ($test instanceof Enlight_Components_Test_Selenium_TestCase && $e instanceof PHPUnit_Framework_ExpectationFailedException && ($screenshot = $test->getFullScreenshot())) {
         $filename = basename($test->getFullScreenshotUrl());
         /** @var $test Enlight_Components_Test_Selenium_TestCase */
         $mail->createAttachment($screenshot, Zend_Mime::TYPE_OCTETSTREAM, Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, $filename);
     }
     $mail->send($this->mailTransport);
 }
Esempio n. 2
0
 /**
  * Loads values from MailModel into Mail
  *
  * @param \Enlight_Components_Mail $mail
  * @param \Shopware\Models\Mail\Mail $mailModel
  * @param array $overrideConfig
  * @return \Enlight_Components_Mail
  * @throws \Enlight_Exception
  */
 public function loadValues(\Enlight_Components_Mail $mail, \Shopware\Models\Mail\Mail $mailModel, $overrideConfig = array())
 {
     $stringCompiler = $this->getStringCompiler();
     $subject = $stringCompiler->compileString($mailModel->getSubject());
     if (!empty($subject)) {
         $mail->setSubject($subject);
     }
     if (!empty($overrideConfig["fromMail"])) {
         $fromMail = $overrideConfig["fromMail"];
     } else {
         $fromMail = $stringCompiler->compileString($mailModel->getFromMail());
     }
     if (!empty($overrideConfig["fromName"])) {
         $fromName = $overrideConfig["fromName"];
     } else {
         $fromName = $stringCompiler->compileString($mailModel->getFromName());
     }
     if (!empty($fromMail) && !empty($fromName)) {
         $mail->setFrom($fromMail, $fromName);
     } elseif (!empty($fromMail)) {
         $mail->setFrom($fromMail);
     }
     $bodyText = $stringCompiler->compileString($mailModel->getContent());
     $mail->setBodyText($bodyText);
     if ($mailModel->isHtml()) {
         $mail->setBodyHtml($stringCompiler->compileString($mailModel->getContentHtml()));
     }
     /** @var $attachment \Shopware\Models\Mail\Attachment */
     foreach ($mailModel->getAttachments() as $attachment) {
         if ($attachment->getShopId() !== null && ($this->getShop() === null || $attachment->getShopId() != $this->getShop()->getId())) {
             continue;
         }
         $mediaService = Shopware()->Container()->get('shopware_media.media_service');
         if (!$mediaService->has($attachment->getPath())) {
             Shopware()->Container()->get('corelogger')->error('Could not load file: ' . $attachment->getPath());
         } else {
             $fileAttachment = $mail->createAttachment($mediaService->read($attachment->getPath()));
             $fileAttachment->filename = $attachment->getFileName();
         }
     }
     return $mail;
 }
Esempio n. 3
0
 /**
  * Loads values from MailModel into Mail
  *
  * @param \Enlight_Components_Mail $mail
  * @param \Shopware\Models\Mail\Mail $mailModel
  * @param array $overrideConfig
  * @return \Enlight_Components_Mail
  * @throws \Enlight_Exception
  */
 public function loadValues(\Enlight_Components_Mail $mail, \Shopware\Models\Mail\Mail $mailModel, $overrideConfig = array())
 {
     $stringCompiler = $this->getStringCompiler();
     $subject = $stringCompiler->compileString($mailModel->getSubject());
     if (!empty($subject)) {
         $mail->setSubject($subject);
     }
     if (!empty($overrideConfig["fromMail"])) {
         $fromMail = $overrideConfig["fromMail"];
     } else {
         $fromMail = $stringCompiler->compileString($mailModel->getFromMail());
     }
     if (!empty($overrideConfig["fromName"])) {
         $fromName = $overrideConfig["fromName"];
     } else {
         $fromName = $stringCompiler->compileString($mailModel->getFromName());
     }
     if (!empty($fromMail) && !empty($fromName)) {
         $mail->setFrom($fromMail, $fromName);
     } elseif (!empty($fromMail)) {
         $mail->setFrom($fromMail);
     }
     $bodyText = $stringCompiler->compileString($mailModel->getContent());
     $mail->setBodyText($bodyText);
     if ($mailModel->isHtml()) {
         $mail->setBodyHtml($stringCompiler->compileString($mailModel->getContentHtml()));
     }
     /** @var $attachment \Shopware\Models\Mail\Attachment */
     foreach ($mailModel->getAttachments() as $attachment) {
         if ($attachment->getShopId() !== null && ($this->getShop() === null || $attachment->getShopId() != $this->getShop()->getId())) {
             continue;
         }
         if (false === ($fileHandle = fopen($attachment->getPath(), 'r'))) {
             throw new \Enlight_Exception('Could not load file: ' . $attachment->getPath());
         }
         $fileAttachment = $mail->createAttachment($fileHandle);
         $fileAttachment->filename = $attachment->getFileName();
     }
     return $mail;
 }