Teste unitário para conferir a configuração de envio de emails no Symfony 1.4 (c/ Swiftmailer)

<?php
/**
* test/unit/maillerTest.php
*
* @author Gilmar Pupo <[email protected]>
*
* Unit Test to check the configuration of sending emails in symfony 1.4 (c / SwiftMailer)
*/

 
require_once dirname(__FILE__).‘/../bootstrap/unit.php’;
$t = new lime_test(1);
require_once sfConfig::get(‘sf_symfony_lib_dir’).‘/vendor/swiftmailer/classes/Swift.php’;
Swift::registerAutoload();
sfMailer::initialize();
$dispatcher = new sfEventDispatcher();
$factories = sfYaml::load(sfConfig::get(‘sf_root_dir’) . ‘/apps/backend/config/factories.yml’);
$mailer = new sfMailer($dispatcher, $factories[‘all’][‘mailer’][‘param’]);
$message = Swift_Message::newInstance(‘Subject test’)
->setFrom(sfConfig::get(‘app_contact_emailfrom’, [email protected]))
->setTo(array([email protected] => ‘Gilmar Pupo’))
->setBody(‘Email content’);
$numSent = $mailer->send($message);
$t->ok( $numSent > 0 );

 

No snippets: http://snippets.symfony-project.org/snippet/441

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *