public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     UserTestHelper::createBasicUser('billy');
     UserTestHelper::createBasicUser('jane');
     $someoneSuper = UserTestHelper::createBasicUser('someoneSuper');
     $group = Group::getByName('Super Administrators');
     $group->users->add($someoneSuper);
     $saved = $group->save();
     assert($saved);
     // Not Coding Standard
     $box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
     SendGrid::register_autoloader();
     Smtpapi::register_autoloader();
     if (SendGridTestHelper::isSetSendGridAccountTestConfiguration()) {
         Yii::app()->sendGridEmailHelper->apiUsername = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiUsername'];
         Yii::app()->sendGridEmailHelper->apiPassword = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiPassword'];
         Yii::app()->sendGridEmailHelper->setApiSettings();
         Yii::app()->sendGridEmailHelper->init();
         static::$testEmailAddress = Yii::app()->params['emailTestAccounts']['testEmailAddress'];
     }
     // Delete item from jobQueue, that is created when new user is created
     Yii::app()->jobQueue->deleteAll();
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     self::$emailHelperSendEmailThroughTransport = Yii::app()->emailHelper->sendEmailThroughTransport;
     static::$userpsg = UserTestHelper::createBasicUser('userpsg');
     static::$usercstmsmtp = UserTestHelper::createBasicUser('usercstmsmtp');
     static::$basicuser = UserTestHelper::createBasicUser('basicuser');
     static::$bothSGandCstmUser = UserTestHelper::createBasicUser('bothSGandCstmUser');
     $someoneSuper = UserTestHelper::createBasicUser('someoneSuper');
     $group = Group::getByName('Super Administrators');
     $group->users->add($someoneSuper);
     $saved = $group->save();
     assert($saved);
     // Not Coding Standard
     $box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
     if (EmailMessageTestHelper::isSetEmailAccountsTestConfiguration()) {
         EmailMessageTestHelper::createEmailAccountForMailerFactory(static::$usercstmsmtp);
         EmailMessageTestHelper::createEmailAccountForMailerFactory(static::$bothSGandCstmUser);
     }
     SendGrid::register_autoloader();
     Smtpapi::register_autoloader();
     if (SendGridTestHelper::isSetSendGridAccountTestConfiguration()) {
         SendGridTestHelper::createSendGridEmailAccount(static::$userpsg);
         SendGridTestHelper::createSendGridEmailAccount(static::$bothSGandCstmUser);
         Yii::app()->sendGridEmailHelper->apiUsername = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiUsername'];
         Yii::app()->sendGridEmailHelper->apiPassword = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiPassword'];
         Yii::app()->sendGridEmailHelper->setApiSettings();
         Yii::app()->sendGridEmailHelper->init();
     }
     // Delete item from jobQueue, that is created when new user is created
     Yii::app()->jobQueue->deleteAll();
 }
 /**
  * Class constructor.
  * @param EmailMessage $emailMessage
  * @param mixed $emailAccount
  */
 public function __construct(EmailMessage $emailMessage, $emailAccount)
 {
     SendGrid::register_autoloader();
     Smtpapi::register_autoloader();
     $from = array('address' => $emailMessage->sender->fromAddress, 'name' => $emailMessage->sender->fromName);
     $this->fromUserEmailData = $from;
     $this->emailMessage = $emailMessage;
     $this->resolveRecipientAddressesByType();
     $this->emailAccount = $emailAccount;
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $super = SecurityTestHelper::createSuperAdmin();
     Yii::app()->user->userModel = $super;
     SendGrid::register_autoloader();
     Smtpapi::register_autoloader();
     if (SendGridTestHelper::isSetSendGridAccountTestConfiguration()) {
         static::$apiUsername = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiUsername'];
         static::$apiPassword = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiPassword'];
         static::$testEmailAddress = Yii::app()->params['emailTestAccounts']['testEmailAddress'];
     }
 }
<?php

include dirname(dirname(__FILE__)) . '/lib/Smtpapi.php';
Smtpapi::register_autoloader();
function autoload_tests($class)
{
    if (strpos($class, 'SmtpapiTest_') !== 0) {
        return;
    }
    $class = substr($class, 13);
    $file = str_replace('_', '/', $class);
    if (file_exists(dirname(__FILE__) . '/' . $file . '.php')) {
        require_once dirname(__FILE__) . '/' . $file . '.php';
    }
}
spl_autoload_register('autoload_tests');