How to use setMailer method of mail class

Best Atoum code snippet using mail.setMailer

RecruitmentMailNotifierTest.php

Source:RecruitmentMailNotifierTest.php Github

copy

Full Screen

...118 public function testSendApplicationReceivedEmailToApplicant() {119 $jobApplication = $this->jobApplications[1];120 $notifier = new RecruitmentMailNotifier();121 $mockMailer = new MockMailer();122 $notifier->setMailer($mockMailer);123 // Check successfull email124 $result = $notifier->sendApplicationReceivedEmailToApplicant($jobApplication);125 $this->assertTrue($result);126 $to = $mockMailer->getTo();127 $this->assertEquals(1, count($to));128 $this->assertEquals('janaka@example.com', $to[0]);129 $subject = $this->_getTemplateFile(RecruitmentMailNotifier::SUBJECT_RECEIVED_APPLICANT);130 $body = $this->_getTemplateFile(RecruitmentMailNotifier::TEMPLATE_RECEIVED_APPLICANT);131 $search = array(RecruitmentMailNotifier::VARIABLE_JOB_TITLE, RecruitmentMailNotifier::VARIABLE_TO);132 $replace = array('Manager', 'Janaka Kulathunga');133 $body = str_replace($search, $replace, $body);134 $subject = str_replace($search, $replace, $subject);135 $subject = str_replace(array("\r", "\n"), array("", ""), $subject);136 $this->assertEquals($subject, $mockMailer->getSubject());137 $this->assertEquals($body, $mockMailer->getBodyText());138 // without to email address - should fail139 $jobApplication->setEmail(null);140 $mockMailer = new MockMailer();141 $notifier->setMailer($mockMailer);142 $result = $notifier->sendApplicationReceivedEmailToApplicant($jobApplication);143 $this->assertFalse($result);144 }145 /**146 * Test case for SendApplicationReceivedEmailToManager().147 */148 public function testSendApplicationReceivedEmailToManager() {149 $jobApplication = $this->jobApplications[1];150 $notifier = new RecruitmentMailNotifier();151 $mockMailer = new MockMailer();152 $notifier->setMailer($mockMailer);153 // Check successfull email154 $result = $notifier->sendApplicationReceivedEmailToManager($jobApplication);155 $this->assertTrue($result);156 $to = $mockMailer->getTo();157 $this->assertEquals(1, count($to));158 $this->assertEquals('aruna@company.com', $to[0]);159 $subject = $this->_getTemplateFile(RecruitmentMailNotifier::SUBJECT_RECEIVED_HIRING_MANAGER);160 $body = $this->_getTemplateFile(RecruitmentMailNotifier::TEMPLATE_RECEIVED_HIRING_MANAGER);161 $search = array(RecruitmentMailNotifier::VARIABLE_JOB_TITLE, RecruitmentMailNotifier::VARIABLE_TO,162 RecruitmentMailNotifier::VARIABLE_APPLICANT_FIRSTNAME, RecruitmentMailNotifier::VARIABLE_APPLICANT_MIDDLENAME,163 RecruitmentMailNotifier::VARIABLE_APPLICANT_LASTNAME, RecruitmentMailNotifier::VARIABLE_APPLICANT_STREET1,164 RecruitmentMailNotifier::VARIABLE_APPLICANT_STREET2, RecruitmentMailNotifier::VARIABLE_APPLICANT_CITY,165 RecruitmentMailNotifier::VARIABLE_APPLICANT_PROVINCE, RecruitmentMailNotifier::VARIABLE_APPLICANT_ZIP,166 RecruitmentMailNotifier::VARIABLE_APPLICANT_COUNTRY, RecruitmentMailNotifier::VARIABLE_APPLICANT_PHONE,167 RecruitmentMailNotifier::VARIABLE_APPLICANT_MOBILE, RecruitmentMailNotifier::VARIABLE_APPLICANT_EMAIL,168 RecruitmentMailNotifier::VARIABLE_APPLICANT_QUALIFICATIONS);169 $replace = array('Manager', 'Saman',170 $jobApplication->getFirstName(), $jobApplication->getMiddleName(),171 $jobApplication->getLastName(), $jobApplication->getStreet1(),172 $jobApplication->getStreet2(), $jobApplication->getCity(),173 $jobApplication->getProvince(), $jobApplication->getZip(),174 'Sri Lanka', $jobApplication->getPhone(),175 $jobApplication->getMobile(), $jobApplication->getEmail(),176 $jobApplication->getQualifications());177 $body = str_replace($search, $replace, $body);178 $subject = str_replace($search, $replace, $subject);179 $subject = str_replace(array("\r", "\n"), array("", ""), $subject);180 $this->assertEquals($subject, $mockMailer->getSubject());181 $this->assertEquals($body, $mockMailer->getBodyText());182 // without to email address - should fail183 $this->_runQuery("UPDATE hs_hr_employee SET emp_work_email=NULL where emp_number = 11");184 $mockMailer = new MockMailer();185 $notifier->setMailer($mockMailer);186 $result = $notifier->sendApplicationReceivedEmailToManager($jobApplication);187 $this->assertFalse($result);188 }189 /**190 * Test case for sendApprovalToHiringManager().191 */192 public function testSendApprovalToHiringManager() {193 $jobApplication = $this->jobApplications[1];194 $notifier = new RecruitmentMailNotifier();195 $mockMailer = new MockMailer();196 $notifier->setMailer($mockMailer);197 $event = JobApplicationEvent::getJobApplicationEvent(1);198 $event->setStatus(JobApplicationEvent::EVENT_APPROVE);199 $event->setNotes('Notes created for unit testing');200 $event->setCreatedBy('USR113');201 $event->save();202 // Check successfull email203 $result = $notifier->sendApprovalToHiringManager($jobApplication, $event);204 $this->assertTrue($result);205 $to = $mockMailer->getTo();206 $this->assertEquals(1, count($to));207 $this->assertEquals('aruna@company.com', $to[0]);208 $subject = $this->_getTemplateFile(RecruitmentMailNotifier::SUBJECT_DIRECTOR_APPROVE);209 $body = $this->_getTemplateFile(RecruitmentMailNotifier::TEMPLATE_DIRECTOR_APPROVE);210 $search = array(RecruitmentMailNotifier::VARIABLE_JOB_TITLE, RecruitmentMailNotifier::VARIABLE_TO,211 RecruitmentMailNotifier::VARIABLE_APPLICANT_FIRSTNAME, RecruitmentMailNotifier::VARIABLE_APPLICANT_MIDDLENAME,212 RecruitmentMailNotifier::VARIABLE_APPLICANT_LASTNAME, RecruitmentMailNotifier::VARIABLE_APPLICANT_STREET1,213 RecruitmentMailNotifier::VARIABLE_APPLICANT_STREET2, RecruitmentMailNotifier::VARIABLE_APPLICANT_CITY,214 RecruitmentMailNotifier::VARIABLE_APPLICANT_PROVINCE, RecruitmentMailNotifier::VARIABLE_APPLICANT_ZIP,215 RecruitmentMailNotifier::VARIABLE_APPLICANT_COUNTRY, RecruitmentMailNotifier::VARIABLE_APPLICANT_PHONE,216 RecruitmentMailNotifier::VARIABLE_APPLICANT_MOBILE, RecruitmentMailNotifier::VARIABLE_APPLICANT_EMAIL,217 RecruitmentMailNotifier::VARIABLE_APPLICANT_QUALIFICATIONS, RecruitmentMailNotifier::VARIABLE_APPROVE_NOTES,218 RecruitmentMailNotifier::VARIABLE_FROM);219 $replace = array('Manager', 'Saman',220 $jobApplication->getFirstName(), $jobApplication->getMiddleName(),221 $jobApplication->getLastName(), $jobApplication->getStreet1(),222 $jobApplication->getStreet2(), $jobApplication->getCity(),223 $jobApplication->getProvince(), $jobApplication->getZip(),224 'Sri Lanka', $jobApplication->getPhone(),225 $jobApplication->getMobile(), $jobApplication->getEmail(),226 $jobApplication->getQualifications(), $event->getNotes(), 'John Samuel');227 $body = str_replace($search, $replace, $body);228 $subject = str_replace($search, $replace, $subject);229 $subject = str_replace(array("\r", "\n"), array("", ""), $subject);230 $this->assertEquals($subject, $mockMailer->getSubject());231 $this->assertEquals($body, $mockMailer->getBodyText());232 // without to email address - should fail233 $this->_runQuery("UPDATE hs_hr_employee SET emp_work_email=NULL where emp_number = 11");234 $mockMailer = new MockMailer();235 $notifier->setMailer($mockMailer);236 $result = $notifier->sendApprovalToHiringManager($jobApplication, $event);237 $this->assertFalse($result);238 }239 /**240 * Test case for sendSeekApprovalToDirector().241 */242 public function testSendSeekApprovalToDirector() {243 $jobApplication = JobApplication::getJobApplication(2);244 $event = $jobApplication->getEventOfType(JobApplicationEvent::EVENT_SEEK_APPROVAL);245 $notifier = new RecruitmentMailNotifier();246 $mockMailer = new MockMailer();247 $notifier->setMailer($mockMailer);248 // Check successfull email249 $result = $notifier->sendSeekApprovalToDirector($jobApplication, $event);250 $this->assertTrue($result);251 $notifier->setMailer($mockMailer);252 $to = $mockMailer->getTo();253 $this->assertEquals(1, count($to));254 $this->assertEquals('mohanjith@mydomain.com', $to[0]);255 $subject = $this->_getTemplateFile(RecruitmentMailNotifier::SUBJECT_SEEK_APPROVAL_DIRECTOR);256 $body = $this->_getTemplateFile(RecruitmentMailNotifier::TEMPLATE_SEEK_APPROVAL_DIRECTOR);257 $search = array(RecruitmentMailNotifier::VARIABLE_JOB_TITLE, RecruitmentMailNotifier::VARIABLE_TO,258 RecruitmentMailNotifier::VARIABLE_APPLICANT_FIRSTNAME, RecruitmentMailNotifier::VARIABLE_APPLICANT_MIDDLENAME,259 RecruitmentMailNotifier::VARIABLE_APPLICANT_LASTNAME, RecruitmentMailNotifier::VARIABLE_APPLICANT_STREET1,260 RecruitmentMailNotifier::VARIABLE_APPLICANT_STREET2, RecruitmentMailNotifier::VARIABLE_APPLICANT_CITY,261 RecruitmentMailNotifier::VARIABLE_APPLICANT_PROVINCE, RecruitmentMailNotifier::VARIABLE_APPLICANT_ZIP,262 RecruitmentMailNotifier::VARIABLE_APPLICANT_COUNTRY, RecruitmentMailNotifier::VARIABLE_APPLICANT_PHONE,263 RecruitmentMailNotifier::VARIABLE_APPLICANT_MOBILE, RecruitmentMailNotifier::VARIABLE_APPLICANT_EMAIL,264 RecruitmentMailNotifier::VARIABLE_APPLICANT_QUALIFICATIONS,265 RecruitmentMailNotifier::VARIABLE_SEEK_NOTES, RecruitmentMailNotifier::VARIABLE_FROM266 );267 $replace = array('Driver', 'John',268 $jobApplication->getFirstName(), $jobApplication->getMiddleName(),269 $jobApplication->getLastName(), $jobApplication->getStreet1(),270 $jobApplication->getStreet2(), $jobApplication->getCity(),271 $jobApplication->getProvince(), $jobApplication->getZip(),272 'England', $jobApplication->getPhone(),273 $jobApplication->getMobile(), $jobApplication->getEmail(),274 $jobApplication->getQualifications(),275 $event->getNotes(), 'Saman Rajasinghe'276 );277 $body = str_replace($search, $replace, $body);278 $subject = str_replace($search, $replace, $subject);279 $subject = str_replace(array("\r", "\n"), array("", ""), $subject);280 $this->assertEquals($subject, $mockMailer->getSubject());281 $this->assertEquals($body, $mockMailer->getBodyText());282 // without to email address - should fail283 $this->_runQuery("UPDATE hs_hr_employee SET emp_work_email=NULL where emp_number = 13");284 $mockMailer = new MockMailer();285 $notifier->setMailer($mockMailer);286 $result = $notifier->sendSeekApprovalToDirector($jobApplication, $event);287 $this->assertFalse($result);288 }289 /**290 * Test the sendInterviewTaskToManager function291 */292 public function testSendInterviewTaskToManager() {293 $jobApplication = $this->jobApplications[1];294 $jobApplication->setStatus(JobApplication::STATUS_FIRST_INTERVIEW_SCHEDULED);295 $jobApplication->save();296 $jobAppEvent = JobApplicationEvent::getJobApplicationEvent(1);297 $notifier = new RecruitmentMailNotifier();298 $mockMailer = new MockMailer();299 $notifier->setMailer($mockMailer);300 $notifier->sendInterviewTaskToManager($jobAppEvent);301 $attachments = $mockMailer->getAttachments();302 $this->assertEquals(2, count($attachments));303 }304 /**305 * Create a JobApplication object with the passed parameters306 */307 private function _getJobApplication($id, $vacancyId, $firstName, $middleName, $lastName, $street1, $street2,308 $city, $province, $zip, $country, $mobile, $phone, $email, $qualifications) {309 $application = new JobApplication($id);310 $application->setVacancyId($vacancyId);311 $application->setFirstName($firstName);312 $application->setMiddleName($middleName);313 $application->setLastName($lastName);...

Full Screen

Full Screen

setMailer

Using AI Code Generation

copy

Full Screen

1$myMail->setMailer('smtp');2$myMail->setHost('smtp.gmail.com');3$myMail->setPort(587);4$myMail->setSMTPAuth(true);5$myMail->setSMTPSecure('tls');6$myMail->setUsername('

Full Screen

Full Screen

setMailer

Using AI Code Generation

copy

Full Screen

1$mail->setMailer('smtp');2$mail->setMailer('sendmail');3$mail->setMailer('mail');4$mail->setMailer('qmail');5$mail->setMailer('sendmail');6$mail->setMailer('smtp');7$mail->setMailer('mail');8$mail->setMailer('qmail');9$mail->setMailer('sendmail');10$mail->setMailer('smtp');11$mail->setMailer('mail');12$mail->setMailer('qmail');13$mail->setMailer('sendmail');14$mail->setMailer('smtp');15$mail->setMailer('mail

Full Screen

Full Screen

setMailer

Using AI Code Generation

copy

Full Screen

1require_once('mail.php');2$mail = new mail();3$mail->setMailer('smtp');4$mail->setSmtpHost('smtp.gmail.com');5$mail->setSmtpPort(25);6$mail->setSmtpUsername('

Full Screen

Full Screen

setMailer

Using AI Code Generation

copy

Full Screen

1require_once 'Mail.php';2require_once 'Mail/mime.php';3$mail = new Mail_mime();4$mail->setHTMLBody("this is a test mail");5$mail->setFrom("test@localhost");6$mail->setSubject("test mail");7$mail->setReturnPath("test@localhost");8$mail->setSMTPParams("localhost", 25, "localhost", false, "test", "test");9$mail->buildMessage();10$mail->send("test@localhost", "mail");11require_once 'Mail.php';12require_once 'Mail/mime.php';13$mail = new Mail_mime();14$mail->setHTMLBody("this is a test mail");15$mail->setFrom("test@localhost");16$mail->setSubject("test mail");17$mail->setReturnPath("test@localhost");18$mail->setSMTPParams("localhost", 25, "localhost", false, "test", "test");19$mail->buildMessage();20$mail->send("test@localhost", "mail");21require_once 'Mail.php';22require_once 'Mail/mime.php';23$mail = new Mail_mime();24$mail->setHTMLBody("this is a test mail");25$mail->setFrom("test@localhost");26$mail->setSubject("test mail");27$mail->setReturnPath("test@localhost");28$mail->setSMTPParams("localhost", 25, "localhost", false, "test", "test");29$mail->buildMessage();30$mail->send("test@localhost", "mail");31require_once 'Mail.php';32require_once 'Mail/mime.php';33$mail = new Mail_mime();34$mail->setHTMLBody("this is a test mail");35$mail->setFrom("test@localhost");36$mail->setSubject("test mail");37$mail->setReturnPath("test@localhost");38$mail->setSMTPParams("localhost", 25, "localhost", false, "test", "test");39$mail->buildMessage();40$mail->send("test@localhost", "mail");41require_once 'Mail.php';42require_once 'Mail/mime.php';43$mail = new Mail_mime();44$mail->setHTMLBody("this is a test mail");45$mail->setFrom("test

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger setMailer code on LambdaTest Cloud Grid

Execute automation tests with setMailer on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful