Best Atoum code snippet using mailer
SwiftmailerExtension.php
Source:SwiftmailerExtension.php
...6 *7 * For the full copyright and license information, please view the LICENSE8 * file that was distributed with this source code.9 */10namespace Symfony\Bundle\SwiftmailerBundle\DependencyInjection;11use Symfony\Component\HttpKernel\DependencyInjection\Extension;12use Symfony\Component\DependencyInjection\DefinitionDecorator;13use Symfony\Component\DependencyInjection\Reference;14use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;15use Symfony\Component\DependencyInjection\ContainerBuilder;16use Symfony\Component\Config\FileLocator;17/**18 * SwiftmailerExtension is an extension for the SwiftMailer library.19 *20 * @author Fabien Potencier <fabien@symfony.com>21 */22class SwiftmailerExtension extends Extension23{24 /**25 * Loads the Swift Mailer configuration.26 *27 * Usage example:28 *29 * <swiftmailer:config transport="gmail">30 * <swiftmailer:username>fabien</swift:username>31 * <swiftmailer:password>xxxxx</swift:password>32 * <swiftmailer:spool path="/path/to/spool/" />33 * </swiftmailer:config>34 *35 * @param array $configs An array of configuration settings36 * @param ContainerBuilder $container A ContainerBuilder instance37 */38 public function load(array $configs, ContainerBuilder $container)39 {40 $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));41 $loader->load('swiftmailer.xml');42 $configuration = $this->getConfiguration($configs, $container);43 $config = $this->processConfiguration($configuration, $configs);44 $mailers = array();45 foreach ($config['mailers'] as $name => $mailer) {46 $isDefaultMailer = $config['default_mailer'] === $name;47 $this->configureMailer($name, $mailer, $container, $isDefaultMailer);48 $mailers[$name] = sprintf('swiftmailer.mailer.%s', $name);49 }50 ksort($mailers);51 $container->setParameter('swiftmailer.mailers', $mailers);52 $container->setParameter('swiftmailer.default_mailer', $config['default_mailer']);53 $container->findDefinition('swiftmailer.data_collector')->addTag('data_collector', array('template' => '@Swiftmailer/Collector/swiftmailer.html.twig', 'id' => 'swiftmailer'));54 $container->setAlias('mailer', 'swiftmailer.mailer');55 }56 protected function configureMailer($name, array $mailer, ContainerBuilder $container, $isDefaultMailer = false)57 {58 if (null === $mailer['transport']) {59 $transport = 'null';60 } elseif ('gmail' === $mailer['transport']) {61 $mailer['encryption'] = 'ssl';62 $mailer['auth_mode'] = 'login';63 $mailer['host'] = 'smtp.gmail.com';64 $transport = 'smtp';65 } else {66 $transport = $mailer['transport'];67 }68 $container->setParameter(sprintf('swiftmailer.mailer.%s.transport.name', $name), $transport);69 if (isset($mailer['disable_delivery']) && $mailer['disable_delivery']) {70 $transport = 'null';71 $container->setParameter(sprintf('swiftmailer.mailer.%s.delivery.enabled', $name), false);72 } else {73 $container->setParameter(sprintf('swiftmailer.mailer.%s.delivery.enabled', $name), true);74 }75 if (empty($mailer['port'])) {76 $mailer['port'] = 'ssl' === $mailer['encryption'] ? 465 : 25;77 }78 $this->configureMailerTransport($name, $mailer, $container, $transport, $isDefaultMailer);79 $this->configureMailerSpool($name, $mailer, $container, $transport, $isDefaultMailer);80 $this->configureMailerSenderAddress($name, $mailer, $container, $isDefaultMailer);81 $this->configureMailerAntiFlood($name, $mailer, $container, $isDefaultMailer);82 $this->configureMailerDeliveryAddress($name, $mailer, $container, $isDefaultMailer);83 $this->configureMailerLogging($name, $mailer, $container, $isDefaultMailer);84 // alias85 if ($isDefaultMailer) {86 $container->setAlias('swiftmailer.mailer', sprintf('swiftmailer.mailer.%s', $name));87 $container->setAlias('swiftmailer.transport', sprintf('swiftmailer.mailer.%s.transport', $name));88 $container->setParameter('swiftmailer.spool.enabled', $container->getParameter(sprintf('swiftmailer.mailer.%s.spool.enabled', $name)));89 $container->setParameter('swiftmailer.delivery.enabled', $container->getParameter(sprintf('swiftmailer.mailer.%s.delivery.enabled', $name)));90 $container->setParameter('swiftmailer.single_address', $container->getParameter(sprintf('swiftmailer.mailer.%s.single_address', $name)));91 }92 }93 protected function configureMailerTransport($name, array $mailer, ContainerBuilder $container, $transport, $isDefaultMailer = false)94 {95 foreach (array('encryption', 'port', 'host', 'username', 'password', 'auth_mode', 'timeout', 'source_ip') as $key) {96 $container->setParameter(sprintf('swiftmailer.mailer.%s.transport.smtp.%s', $name, $key), $mailer[$key]);97 }98 $definitionDecorator = new DefinitionDecorator('swiftmailer.transport.eventdispatcher.abstract');99 $container100 ->setDefinition(sprintf('swiftmailer.mailer.%s.transport.eventdispatcher', $name), $definitionDecorator)101 ;102 if ('smtp' === $transport) {103 $authDecorator = new DefinitionDecorator('swiftmailer.transport.authhandler.abstract');104 $container105 ->setDefinition(sprintf('swiftmailer.mailer.%s.transport.authhandler', $name), $authDecorator)106 ->addMethodCall('setUsername', array('%swiftmailer.mailer.' . $name . '.transport.smtp.username%'))107 ->addMethodCall('setPassword', array('%swiftmailer.mailer.' . $name . '.transport.smtp.password%'))108 ->addMethodCall('setAuthMode', array('%swiftmailer.mailer.' . $name . '.transport.smtp.auth_mode%'));109 $bufferDecorator = new DefinitionDecorator('swiftmailer.transport.buffer.abstract');110 $container111 ->setDefinition(sprintf('swiftmailer.mailer.%s.transport.buffer', $name), $bufferDecorator);112 $definitionDecorator = new DefinitionDecorator('swiftmailer.transport.smtp.abstract');113 $container114 ->setDefinition(sprintf('swiftmailer.mailer.%s.transport.smtp', $name), $definitionDecorator)115 ->setArguments(array(116 new Reference(sprintf('swiftmailer.mailer.%s.transport.buffer', $name)),117 array(new Reference(sprintf('swiftmailer.mailer.%s.transport.authhandler', $name))),118 new Reference(sprintf('swiftmailer.mailer.%s.transport.eventdispatcher', $name)),119 ))120 ->addMethodCall('setHost', array('%swiftmailer.mailer.' . $name . '.transport.smtp.host%'))121 ->addMethodCall('setPort', array('%swiftmailer.mailer.' . $name . '.transport.smtp.port%'))122 ->addMethodCall('setEncryption', array('%swiftmailer.mailer.' . $name . '.transport.smtp.encryption%'))123 ->addMethodCall('setTimeout', array('%swiftmailer.mailer.' . $name . '.transport.smtp.timeout%'))124 ->addMethodCall('setSourceIp', array('%swiftmailer.mailer.' . $name . '.transport.smtp.source_ip%'))125 ;126 $container->setAlias(sprintf('swiftmailer.mailer.%s.transport', $name), sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport));127 } elseif ('sendmail' === $transport) {128 $bufferDecorator = new DefinitionDecorator('swiftmailer.transport.buffer.abstract');129 $container130 ->setDefinition(sprintf('swiftmailer.mailer.%s.transport.buffer', $name), $bufferDecorator);131 $definitionDecorator = new DefinitionDecorator(sprintf('swiftmailer.transport.%s.abstract', $transport));132 $container133 ->setDefinition(sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport), $definitionDecorator)134 ->setArguments(array(135 new Reference(sprintf('swiftmailer.mailer.%s.transport.buffer', $name)),136 new Reference(sprintf('swiftmailer.mailer.%s.transport.eventdispatcher', $name))137 ))138 ;139 $container->setAlias(sprintf('swiftmailer.mailer.%s.transport', $name), sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport));140 } elseif ('mail' === $transport) {141 $definitionDecorator = new DefinitionDecorator(sprintf('swiftmailer.transport.%s.abstract', $transport));142 $container143 ->setDefinition(sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport), $definitionDecorator)144 ->addArgument(new Reference(sprintf('swiftmailer.mailer.%s.transport.eventdispatcher', $name)))145 ;146 $container->setAlias(sprintf('swiftmailer.mailer.%s.transport', $name), sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport));147 } elseif ('null' === $transport) {148 $definitionDecorator = new DefinitionDecorator('swiftmailer.transport.null.abstract');149 $container150 ->setDefinition(sprintf('swiftmailer.mailer.%s.transport.null', $name, $transport), $definitionDecorator)151 ->setArguments(array(152 new Reference(sprintf('swiftmailer.mailer.%s.transport.eventdispatcher', $name)),153 ))154 ;155 $container->setAlias(sprintf('swiftmailer.mailer.%s.transport', $name), sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport));156 } else {157 $container->setAlias(sprintf('swiftmailer.mailer.%s.transport', $name), sprintf('swiftmailer.mailer.transport.%s', $transport));158 }159 $definitionDecorator = new DefinitionDecorator('swiftmailer.mailer.abstract');160 $container161 ->setDefinition(sprintf('swiftmailer.mailer.%s', $name), $definitionDecorator)162 ->replaceArgument(0, new Reference(sprintf('swiftmailer.mailer.%s.transport', $name)))163 ;164 }165 protected function configureMailerSpool($name, array $mailer, ContainerBuilder $container, $transport, $isDefaultMailer = false)166 {167 if (isset($mailer['spool'])) {168 $type = $mailer['spool']['type'];169 if ('service' === $type) {170 $container->setAlias(sprintf('swiftmailer.mailer.%s.spool.service', $name), $mailer['spool']['id']);171 } else {172 foreach (array('path') as $key) {173 $container->setParameter(sprintf('swiftmailer.spool.%s.%s.%s', $name, $type, $key), $mailer['spool'][$key] . '/' . $name);174 }175 }176 $definitionDecorator = new DefinitionDecorator(sprintf('swiftmailer.spool.%s.abstract', $type));177 if ('file' === $type) {178 $container179 ->setDefinition(sprintf('swiftmailer.mailer.%s.spool.file', $name), $definitionDecorator)180 ->replaceArgument(0, sprintf('%%swiftmailer.spool.%s.file.path%%', $name))181 ;182 } elseif ('memory' === $type) {183 $container184 ->setDefinition(sprintf('swiftmailer.mailer.%s.spool.memory', $name), $definitionDecorator)185 ;186 }187 $container->setAlias(sprintf('swiftmailer.mailer.%s.spool', $name), sprintf('swiftmailer.mailer.%s.spool.%s', $name, $type));188 $definitionDecorator = new DefinitionDecorator('swiftmailer.transport.spool.abstract');189 $container190 ->setDefinition(sprintf('swiftmailer.mailer.%s.transport.spool', $name), $definitionDecorator)191 ->setArguments(array(192 new Reference(sprintf('swiftmailer.mailer.%s.transport.eventdispatcher', $name)),193 new Reference(sprintf('swiftmailer.mailer.%s.spool', $name)),194 ))195 ;196 if (in_array($transport, array('smtp', 'mail', 'sendmail', 'null'))) {197 // built-in transport198 $transport = sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport);199 }200 $container->setAlias(sprintf('swiftmailer.mailer.%s.transport.real', $name), $transport);201 $container->setAlias(sprintf('swiftmailer.mailer.%s.transport', $name), sprintf('swiftmailer.mailer.%s.transport.spool', $name));202 $container->setParameter(sprintf('swiftmailer.mailer.%s.spool.enabled', $name), true);203 if (true === $isDefaultMailer) {204 $container->setAlias('swiftmailer.spool', sprintf('swiftmailer.mailer.%s.spool', $name));205 $container->setAlias('swiftmailer.transport.real', sprintf('swiftmailer.mailer.%s.transport.real', $name));206 }207 } else {208 $container->setParameter(sprintf('swiftmailer.mailer.%s.spool.enabled', $name), false);209 }210 }211 protected function configureMailerSenderAddress($name, array $mailer, ContainerBuilder $container, $isDefaultMailer = false)212 {213 if (isset($mailer['sender_address']) && $mailer['sender_address']) {214 $container->setParameter(sprintf('swiftmailer.mailer.%s.sender_address', $name), $mailer['sender_address']);215 $definitionDecorator = new DefinitionDecorator('swiftmailer.plugin.impersonate.abstract');216 $container217 ->setDefinition(sprintf('swiftmailer.mailer.%s.plugin.impersonate', $name), $definitionDecorator)218 ->setArguments(array(219 sprintf('%%swiftmailer.mailer.%s.sender_address%%', $name),220 ))221 ;222 $container->getDefinition(sprintf('swiftmailer.mailer.%s.plugin.impersonate', $name))->addTag(sprintf('swiftmailer.%s.plugin', $name));223 if (true === $isDefaultMailer) {224 $container->setAlias('swiftmailer.plugin.impersonate', sprintf('swiftmailer.mailer.%s.plugin.impersonate', $name));225 $container->setParameter('swiftmailer.sender_address', $container->getParameter(sprintf('swiftmailer.mailer.%s.sender_address', $name)));226 }227 } else {228 $container->setParameter(sprintf('swiftmailer.mailer.%s.plugin.impersonate', $name), null);229 }230 }231 protected function configureMailerAntiFlood($name, array $mailer, ContainerBuilder $container, $isDefaultMailer = false)232 {233 if (isset($mailer['antiflood'])) {234 $container->setParameter(sprintf('swiftmailer.mailer.%s.antiflood.threshold', $name), $mailer['antiflood']['threshold']);235 $container->setParameter(sprintf('swiftmailer.mailer.%s.antiflood.sleep', $name), $mailer['antiflood']['sleep']);236 $definitionDecorator = new DefinitionDecorator('swiftmailer.plugin.antiflood.abstract');237 $container238 ->setDefinition(sprintf('swiftmailer.mailer.%s.plugin.antiflood', $name), $definitionDecorator)239 ->setArguments(array(240 sprintf('%%swiftmailer.mailer.%s.antiflood.threshold%%', $name),241 sprintf('%%swiftmailer.mailer.%s.antiflood.sleep%%', $name),242 ))243 ;244 $container->getDefinition(sprintf('swiftmailer.mailer.%s.plugin.antiflood', $name))->addTag(sprintf('swiftmailer.%s.plugin', $name));245 if (true === $isDefaultMailer) {246 $container->setAlias('swiftmailer.mailer.plugin.antiflood', sprintf('swiftmailer.mailer.%s.plugin.antiflood', $name));247 }248 }249 }250 protected function configureMailerDeliveryAddress($name, array $mailer, ContainerBuilder $container, $isDefaultMailer = false)251 {252 if (isset($mailer['delivery_address']) && $mailer['delivery_address']) {253 $container->setParameter(sprintf('swiftmailer.mailer.%s.single_address', $name), $mailer['delivery_address']);254 $container->setParameter(sprintf('swiftmailer.mailer.%s.delivery_whitelist', $name), $mailer['delivery_whitelist']);255 $definitionDecorator = new DefinitionDecorator('swiftmailer.plugin.redirecting.abstract');256 $container257 ->setDefinition(sprintf('swiftmailer.mailer.%s.plugin.redirecting', $name), $definitionDecorator)258 ->setArguments(array(259 sprintf('%%swiftmailer.mailer.%s.single_address%%', $name),260 sprintf('%%swiftmailer.mailer.%s.delivery_whitelist%%', $name),261 ))262 ;263 $container->getDefinition(sprintf('swiftmailer.mailer.%s.plugin.redirecting', $name))->addTag(sprintf('swiftmailer.%s.plugin', $name));264 if (true === $isDefaultMailer) {265 $container->setAlias('swiftmailer.plugin.redirecting', sprintf('swiftmailer.mailer.%s.plugin.redirecting', $name));266 }267 } else {268 $container->setParameter(sprintf('swiftmailer.mailer.%s.single_address', $name), null);269 }270 }271 protected function configureMailerLogging($name, array $mailer, ContainerBuilder $container, $isDefaultMailer = false)272 {273 if ($mailer['logging']) {274 $container->getDefinition('swiftmailer.plugin.messagelogger.abstract');275 $definitionDecorator = new DefinitionDecorator('swiftmailer.plugin.messagelogger.abstract');276 $container277 ->setDefinition(sprintf('swiftmailer.mailer.%s.plugin.messagelogger', $name), $definitionDecorator)278 ;279 $container->getDefinition(sprintf('swiftmailer.mailer.%s.plugin.messagelogger', $name))->addTag(sprintf('swiftmailer.%s.plugin', $name));280 if (true === $isDefaultMailer) {281 $container->setAlias('swiftmailer.plugin.messagelogger', sprintf('swiftmailer.mailer.%s.plugin.messagelogger', $name));282 }283 }284 }285 /**286 * Returns the base path for the XSD files.287 *288 * @return string The XSD base path289 */290 public function getXsdValidationBasePath()291 {292 return __DIR__.'/../Resources/config/schema';293 }294 /**295 * Returns the namespace to be used for this extension (XML namespace).296 *297 * @return string The XML namespace298 */299 public function getNamespace()300 {301 return 'http://symfony.com/schema/dic/swiftmailer';302 }303 public function getConfiguration(array $config, ContainerBuilder $container)304 {305 return new Configuration($container->getParameter('kernel.debug'));306 }307}...
MailerLog.php
Source:MailerLog.php
...6 const SETTING_NAME = 'mta_log';7 const STATUS_PAUSED = 'paused';8 const RETRY_ATTEMPTS_LIMIT = 3;9 const RETRY_INTERVAL = 120; // seconds10 public static function getMailerLog($mailerLog = false) {11 if ($mailerLog) return $mailerLog;12 $settings = SettingsController::getInstance();13 $mailerLog = $settings->get(self::SETTING_NAME);14 if (!$mailerLog) {15 $mailerLog = self::createMailerLog();16 }17 return $mailerLog;18 }19 public static function createMailerLog() {20 $mailerLog = [21 'sent' => null,22 'started' => time(),23 'status' => null,24 'retry_attempt' => null,25 'retry_at' => null,26 'error' => null,27 ];28 $settings = SettingsController::getInstance();29 $settings->set(self::SETTING_NAME, $mailerLog);30 return $mailerLog;31 }32 public static function resetMailerLog() {33 return self::createMailerLog();34 }35 public static function updateMailerLog($mailerLog) {36 $settings = SettingsController::getInstance();37 $settings->set(self::SETTING_NAME, $mailerLog);38 return $mailerLog;39 }40 public static function enforceExecutionRequirements($mailerLog = false) {41 $mailerLog = self::getMailerLog($mailerLog);42 if ($mailerLog['retry_attempt'] === self::RETRY_ATTEMPTS_LIMIT) {43 $mailerLog = self::pauseSending($mailerLog);44 }45 if (self::isSendingPaused($mailerLog)) {46 throw new \Exception(__('Sending has been paused.', 'mailpoet'));47 }48 if (!is_null($mailerLog['retry_at'])) {49 if (time() <= $mailerLog['retry_at']) {50 throw new \Exception(__('Sending is waiting to be retried.', 'mailpoet'));51 } else {52 $mailerLog['retry_at'] = null;53 self::updateMailerLog($mailerLog);54 }55 }56 // ensure that sending frequency has not been reached57 if (self::isSendingLimitReached($mailerLog)) {58 throw new \Exception(__('Sending frequency limit has been reached.', 'mailpoet'));59 }60 }61 public static function pauseSending($mailerLog) {62 $mailerLog['status'] = self::STATUS_PAUSED;63 $mailerLog['retry_attempt'] = null;64 $mailerLog['retry_at'] = null;65 return self::updateMailerLog($mailerLog);66 }67 public static function resumeSending() {68 return self::resetMailerLog();69 }70 /**71 * Process error, doesn't increase retry_attempt so it will not block sending72 *73 * @param string $operation74 * @param string $errorMessage75 * @param int $retryInterval76 *77 * @throws \Exception78 */79 public static function processNonBlockingError($operation, $errorMessage, $retryInterval = self::RETRY_INTERVAL) {80 $mailerLog = self::getMailerLog();81 $mailerLog['retry_at'] = time() + $retryInterval;82 $mailerLog = self::setError($mailerLog, $operation, $errorMessage);83 self::updateMailerLog($mailerLog);84 self::enforceExecutionRequirements();85 }86 /**87 * Process error, increase retry_attempt and block sending if it goes above RETRY_INTERVAL88 *89 * @param string $operation90 * @param string $errorMessage91 * @param string $errorCode92 * @param bool $pauseSending93 *94 * @throws \Exception95 */96 public static function processError($operation, $errorMessage, $errorCode = null, $pauseSending = false, $throttledBatchSize = null) {97 $mailerLog = self::getMailerLog();98 if (!isset($throttledBatchSize) || $throttledBatchSize === 1) {99 $mailerLog['retry_attempt']++;100 }101 $mailerLog['retry_at'] = time() + self::RETRY_INTERVAL;102 $mailerLog = self::setError($mailerLog, $operation, $errorMessage, $errorCode);103 self::updateMailerLog($mailerLog);104 if ($pauseSending) {105 self::pauseSending($mailerLog);106 }107 self::enforceExecutionRequirements();108 }109 public static function setError($mailerLog, $operation, $errorMessage, $errorCode = null) {110 $mailerLog['error'] = [111 'operation' => $operation,112 'error_message' => $errorMessage,113 ];114 if ($errorCode) {115 $mailerLog['error']['error_code'] = $errorCode;116 }117 return $mailerLog;118 }119 public static function getError($mailerLog = false) {120 $mailerLog = self::getMailerLog($mailerLog);121 return isset($mailerLog['error']) ? $mailerLog['error'] : null;122 }123 public static function incrementSentCount() {124 $mailerLog = self::getMailerLog();125 // do not increment count if sending limit is reached126 if (self::isSendingLimitReached($mailerLog)) return;127 // clear previous retry count, errors, etc.128 if ($mailerLog['error']) {129 $mailerLog = self::clearSendingErrorLog($mailerLog);130 }131 (int)$mailerLog['sent']++;132 return self::updateMailerLog($mailerLog);133 }134 public static function clearSendingErrorLog($mailerLog) {135 $mailerLog['retry_attempt'] = null;136 $mailerLog['retry_at'] = null;137 $mailerLog['error'] = null;138 return self::updateMailerLog($mailerLog);139 }140 public static function isSendingLimitReached($mailerLog = false) {141 $settings = SettingsController::getInstance();142 $mailerConfig = $settings->get(Mailer::MAILER_CONFIG_SETTING_NAME);143 // do not enforce sending limit for MailPoet's sending method144 if ($mailerConfig['method'] === Mailer::METHOD_MAILPOET) return false;145 $mailerLog = self::getMailerLog($mailerLog);146 $elapsedTime = time() - (int)$mailerLog['started'];147 if (empty($mailer['frequency'])) {148 $defaultSettings = $settings->getAllDefaults();149 $mailer['frequency'] = $defaultSettings['mta']['frequency'];150 }151 $frequencyInterval = (int)$mailerConfig['frequency']['interval'] * Mailer::SENDING_LIMIT_INTERVAL_MULTIPLIER;152 $frequencyLimit = (int)$mailerConfig['frequency']['emails'];153 if ($mailerLog['sent'] >= $frequencyLimit) {154 if ($elapsedTime <= $frequencyInterval) return true;155 // reset mailer log as enough time has passed since the limit was reached156 self::resetMailerLog();157 }158 return false;159 }160 public static function isSendingPaused($mailerLog = false) {161 $mailerLog = self::getMailerLog($mailerLog);162 return $mailerLog['status'] === self::STATUS_PAUSED;163 }164}...
mailer
Using AI Code Generation
1require_once 'vendor/autoload.php';2use atoum\atoum;3$report = new atoum\reports\realtime\cli();4$report->addWriter(new atoum\writers\std\out());5$runner->addReport($report);6$runner->run();7require_once 'vendor/autoload.php';8use atoum\atoum;9$report = new atoum\reports\realtime\cli();10$report->addWriter(new atoum\writers\std\out());11$runner->addReport($report);12$runner->run();13require_once 'vendor/autoload.php';14use atoum\atoum;15$report = new atoum\reports\realtime\cli();16$report->addWriter(new atoum\writers\std\out());17$runner->addReport($report);18$runner->run();
mailer
Using AI Code Generation
1require_once "vendor/autoload.php";2use \mageekguy\atoum\reports\realtime\cli;3use \mageekguy\atoum\reports\realtime;4use \mageekguy\atoum\writers\std;5use \mageekguy\atoum\reports;6use \mageekguy\atoum\report\fields\runner\result\logo;7use \mageekguy\atoum\report\fields\runner\result\duration;8use \mageekguy\atoum\report\fields\runner\result\memory;9use \mageekguy\atoum\report\fields\runner\failures\error;10use \mageekguy\atoum\report\fields\runner\failures\exception;11use \mageekguy\atoum\report\fields\runner\failures\failure;12use \mageekguy\atoum\report\fields\runner\outputs;13use \mageekguy\atoum\report\fields\runner\failures;14use \mageekguy\atoum\report\fields\runner\exceptions;15use \mageekguy\atoum\report\fields\runner\errors;16use \mageekguy\atoum\report\fields\runner\tests;17use \mageekguy\atoum\report\fields\runner\test\duration;18use \mageekguy\atoum\report\fields\runner\test\memory;19use \mageekguy\atoum\report\fields\runner\test\void;20use \mageekguy\atoum\report\fields\runner\test\uncompleted;21use \mageekguy\atoum\report\fields\runner\test\output;22use \mageekguy\atoum\report\fields\runner\test\error;23use \mageekguy\atoum\report\fields\runner\test\exception;24use \mageekguy\atoum\report\fields\runner\test\failure;25use \mageekguy\atoum\report\fields\runner\test\run\duration;
mailer
Using AI Code Generation
1$atoum = new \mageekguy\atoum\scripts\runner();2$atoum->setRootDirectory(__DIR__);3$atoum->setBootstrapFile($atoum->getRootDirectory() . '/bootstrap.php');4$atoum->setPhpPath('/usr/bin/php');5$atoum->setPhpConfigFile($atoum->getRootDirectory() . '/php.ini');6$atoum->setTestDirectory($atoum->getRootDirectory() . '/tests/units');7$atoum->setTestedClassName('mageekguy\atoum\mail\transport');8$atoum->setTestNamespace('mageekguy\atoum\tests\units\mail\transport');9$atoum->setTestedClassNamespace('mageekguy\atoum\mail\transport');10$atoum->setOutputDirectory($atoum->getRootDirectory() . '/tests/units');11$atoum->setLocale('en_US');12$atoum->setScoreFile($atoum->getRootDirectory() . '/score');13$atoum->setXunitReportPath($atoum->getRootDirectory() . '/xunit.xml');14$atoum->setCodeCoverageReportPath($atoum->getRootDirectory() . '/clover.xml');15$atoum->setCodeCoverageHtmlReportPath($atoum->getRootDirectory() . '/html');16$atoum->setUseDefaultReport(false);17$atoum->setUseDefaultRunner(false);18$atoum->setUseDefaultXunitReport(false);19$atoum->setUseDefaultCodeCoverageReport(false);20$atoum->setUseDefaultCodeCoverageHtmlReport(false);21$atoum->setTitle('mageekguy\atoum\mail\transport');22$atoum->setAdapterClass('mageekguy\atoum\adapter');23$atoum->setAssertionManagerClass('mageekguy\atoum\assertionManager');24$atoum->setAsserterClass('mageekguy\atoum\asserter');25$atoum->setTestClass('mageekguy\atoum\test');26$atoum->setTestedClass(new \reflectionClass('mageekguy\atoum\mail
mailer
Using AI Code Generation
1\mageekguy\atoum\mail\protocol\smtp\transport\stream;2\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter;3\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter\buffer;4\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter\socket;5\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter\socket\ssl;6\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter\socket\tls;7\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter\socket\context;8\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter\socket\context\options;9\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter\socket\context\parameters;10\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter\socket\context\parameters\certificate;11\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter\socket\context\parameters\certificate\file;12\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter\socket\context\parameters\certificate\file\authority;13\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter\socket\context\parameters\certificate\file\peer;14\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter\socket\context\parameters\certificate\file\peer\name;15\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter\socket\context\parameters\certificate\file\peer\fingerprint;16\mageekguy\atoum\mail\protocol\smtp\transport\stream\adapter\socket\context\parameters\certificate\file\peer\publicKey;
mailer
Using AI Code Generation
1use atoum\atoum\test;2use atoum\atoum\mock;3class test extends test {4 public function setUp()5 {6 $this->getMockGenerator()->shunt('__construct');7 $mailer = new mock\mailer();8 $mailer->getMockController()->send = function() { return true; };9 $this->setMailer($mailer);10 }11}12use atoum\atoum\test;13use atoum\atoum\mock;14class test extends test {15 public function setUp()16 {17 $this->getMockGenerator()->shunt('__construct');18 $mailer = new mock\mailer();19 $mailer->getMockController()->send = function() { return true; };20 $this->setMailer($mailer);21 }22}23use atoum\atoum\test;24use atoum\atoum\mock;25class test extends test {26 public function setUp()27 {28 $this->getMockGenerator()->shunt('__construct');29 $mailer = new mock\mailer();30 $mailer->getMockController()->send = function() { return true; };31 $this->setMailer($mailer);32 }33}34use atoum\atoum\test;35use atoum\atoum\mock;36class test extends test {37 public function setUp()38 {39 $this->getMockGenerator()->shunt('__construct');40 $mailer = new mock\mailer();41 $mailer->getMockController()->send = function() { return true; };42 $this->setMailer($mailer);43 }44}45use atoum\atoum\test;46use atoum\atoum\mock;47class test extends test {48 public function setUp()49 {50 $this->getMockGenerator()->shunt('__construct');51 $mailer = new mock\mailer();52 $mailer->getMockController()->send = function() { return true; };53 $this->setMailer($mailer);54 }55}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.
Test now for FreeGet 100 minutes of automation test minutes FREE!!