/** * Test case method */ public function testMailTransport() { $mailTransport = Shopware()->MailTransport(); $mail = new Enlight_Components_Mail(); $mail->setBodyText('Test Hallo'); $mail->addTo('*****@*****.**'); $mail = $mail->send($mailTransport); $this->assertInstanceOf('Zend_Mail', $mail); }
/** * 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); }
/** * @return BufferHandler */ public function createMailHandler() { $mailer = new \Enlight_Components_Mail(); $mailer->addTo(Shopware()->Config()->Mail); $mailer->setSubject('Error in shop "' . Shopware()->Config()->Shopname . '".'); $mailHandler = new EnlightMailHandler($mailer, \Monolog\Logger::WARNING); $mailHandler->pushProcessor(new ShopwareEnvironmentProcessor()); $mailHandler->setFormatter(new HtmlFormatter()); $bufferedHandler = new BufferHandler($mailHandler); return $bufferedHandler; }
/** * Sets the given Zend_Log object into the internal log property. * If no log given, a new instance with the internal configuration will be created. * @param Enlight_Components_Log|Zend_Log $log */ public function setResource(Zend_Log $log = null) { if ($log === null) { $log = new Enlight_Components_Log(); $log->setEventItem('date', Zend_Date::now()); $log->addWriter(new Zend_Log_Writer_Null()); $config = $this->Config(); if(!empty($config->logDb)) { $writer = Zend_Log_Writer_Db::factory(array( 'db' => Shopware()->Db(), 'table' => 's_core_log', 'columnmap' => array( 'type' => 'priority', 'key' => 'priorityName', 'text' => 'message', 'date' => 'date', 'ip_address' => 'remote_address', 'user_agent' => 'user_agent', ) )); $writer->addFilter(Enlight_Components_Log::WARN); $log->addWriter($writer); } if(!empty($config->logMail)) { $mail = new Enlight_Components_Mail(); $mail->addTo(Shopware()->Config()->Mail); $writer = new Zend_Log_Writer_Mail($mail); $writer->setSubjectPrependText('Fehler im Shop "'.Shopware()->Config()->Shopname.'" aufgetreten!'); $writer->addFilter(Enlight_Components_Log::WARN); $log->addWriter($writer); } } $this->log = $log; }