PageRenderTime 47ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/models/recruitment/RecruitmentMailNotifierTest.php

https://bitbucket.org/wildanm/orangehrm
PHP | 508 lines | 340 code | 96 blank | 72 comment | 3 complexity | 9440544005606388d027ae780fa299ff MD5 | raw file
Possible License(s): CC-BY-SA-3.0, AGPL-3.0, BSD-3-Clause, AGPL-1.0, GPL-2.0, LGPL-2.1, LGPL-3.0
  1. <?php
  2. // Call RecruitmentMailNotifierTest::main() if this source file is executed directly.
  3. if (!defined("PHPUnit_MAIN_METHOD")) {
  4. define("PHPUnit_MAIN_METHOD", "RecruitmentMailNotifierTest::main");
  5. }
  6. require_once "PHPUnit/Framework/TestCase.php";
  7. require_once "PHPUnit/Framework/TestSuite.php";
  8. require_once "testConf.php";
  9. require_once ROOT_PATH."/lib/confs/Conf.php";
  10. require_once ROOT_PATH."/lib/confs/sysConf.php";
  11. require_once ROOT_PATH."/lib/models/recruitment/JobApplication.php";
  12. require_once ROOT_PATH."/lib/models/recruitment/JobVacancy.php";
  13. require_once ROOT_PATH."/lib/common/UniqueIDGenerator.php";
  14. require_once ROOT_PATH . '/lib/models/eimadmin/EmailNotificationConfiguration.php';
  15. require_once 'RecruitmentMailNotifier.php';
  16. /**
  17. * Test class for RecruitmentMailNotifier.
  18. * Generated by PHPUnit_Util_Skeleton on 2008-02-15 at 16:39:38.
  19. */
  20. class RecruitmentMailNotifierTest extends PHPUnit_Framework_TestCase {
  21. private $jobApplications;
  22. /**
  23. * Runs the test methods of this class.
  24. *
  25. * @access public
  26. * @static
  27. */
  28. public static function main() {
  29. require_once "PHPUnit/TextUI/TestRunner.php";
  30. $suite = new PHPUnit_Framework_TestSuite("RecruitmentMailNotifierTest");
  31. $result = PHPUnit_TextUI_TestRunner::run($suite);
  32. }
  33. /**
  34. * Sets up the fixture, for example, open a network connection.
  35. * This method is called before a test is executed.
  36. *
  37. * @access protected
  38. */
  39. protected function setUp() {
  40. $conf = new Conf();
  41. $this->connection = mysql_connect($conf->dbhost.":".$conf->dbport, $conf->dbuser, $conf->dbpass);
  42. mysql_select_db($conf->dbname);
  43. $this->_deleteTables();
  44. // Insert job titles
  45. $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " .
  46. "VALUES('JOB001', 'Manager', 'Manager job title', 'no comments', null)");
  47. $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " .
  48. "VALUES('JOB002', 'Driver', 'Driver job title', 'no comments', null)");
  49. $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " .
  50. "VALUES('JOB003', 'Director', 'Director job title', 'no comments', null)");
  51. // Insert employees (managers)
  52. $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code, emp_work_email) " .
  53. "VALUES(11, '0011', 'Rajasinghe', 'Saman', 'Marlon', 'JOB001', 'aruna@company.com')");
  54. $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code, emp_work_email) " .
  55. "VALUES(12, '0022', 'Jayasinghe', 'Aruna', 'Shantha', 'JOB001', 'arnold@mydomain.com')");
  56. // Insert director
  57. $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code, emp_work_email) " .
  58. "VALUES(13, '0032', 'Samuel', 'John', 'A', 'JOB003', 'mohanjith@mydomain.com')");
  59. // Insert to hs_hr_users table
  60. $this->_runQuery("INSERT INTO `hs_hr_users`(id, user_name, emp_number) VALUES ('USR111','demo', 11)");
  61. $this->_runQuery("INSERT INTO `hs_hr_users`(id, user_name, emp_number) VALUES ('USR113','director', 13)");
  62. // Insert Job Vacancies
  63. $this->_runQuery("INSERT INTO hs_hr_job_vacancy(vacancy_id, jobtit_code, manager_id, active, description) " .
  64. "VALUES(1, 'JOB001', 11, " . JobVacancy::STATUS_ACTIVE . ", 'Job vacancy 1')");
  65. $this->_runQuery("INSERT INTO hs_hr_job_vacancy(vacancy_id, jobtit_code, manager_id, active, description) " .
  66. "VALUES(2, 'JOB002', 12, " . JobVacancy::STATUS_INACTIVE . ", 'Job vacancy 2')");
  67. // Insert Job Applications
  68. $application = $this->_getJobApplication(1, 1, 'Janaka', 'T', 'Kulathunga', '111 Main Street', 'Apt X2',
  69. 'Colombo', 'Western', '2222', 'Sri Lanka', '01121111121', '077282828282', 'janaka@example.com',
  70. 'aaa bbb');
  71. $this->jobApplications[1] = $application;
  72. $application = $this->_getJobApplication(2, 2, 'Kamal', 'S', 'Thilakarathne', '33 Main Street', 'Apt A1',
  73. 'Badulla', 'Uwa', '112', 'England', '01121133333', '07711112', 'kamal@example.com',
  74. 'some comments');
  75. $this->jobApplications[2] = $application;
  76. $this->_createJobApplications($this->jobApplications);
  77. // Create Job Application Event
  78. $createdTime = date(LocaleUtil::STANDARD_TIMESTAMP_FORMAT);
  79. $eventTime = date(LocaleUtil::STANDARD_TIMESTAMP_FORMAT, strtotime("+5 days"));
  80. $this->_runQuery("INSERT INTO `hs_hr_job_application_events`(`id`,`application_id`,`created_time`," .
  81. "`created_by`, `owner`, `event_time`, `event_type`, `status`, `notes`) VALUES (" .
  82. "1, 1, '". $createdTime ."', 'USR111', 12, '".$eventTime."', " . JobApplicationEvent::EVENT_SCHEDULE_FIRST_INTERVIEW . "," .
  83. JobApplicationEvent::STATUS_INTERVIEW_SCHEDULED . "," . "'Interview notes are here')");
  84. // seek approval event for job application 2
  85. $this->_runQuery("INSERT INTO `hs_hr_job_application_events`(`id`,`application_id`,`created_time`," .
  86. "`created_by`, `owner`, `event_time`, `event_type`, `status`, `notes`) VALUES (" .
  87. "2, 2, '". $createdTime ."', 'USR111', 13, '".$eventTime."', " . JobApplicationEvent::EVENT_SEEK_APPROVAL . "," .
  88. "null," . "'Please approve hire of this person')");
  89. UniqueIDGenerator::getInstance()->resetIDs();
  90. }
  91. /**
  92. * Tears down the fixture, removed database entries created during test.
  93. *
  94. * @access protected
  95. */
  96. protected function tearDown() {
  97. $this->_deleteTables();
  98. UniqueIDGenerator::getInstance()->resetIDs();
  99. }
  100. private function _deleteTables() {
  101. $this->_runQuery("DELETE FROM `hs_hr_users` WHERE id in ('USR111', 'USR113') ");
  102. $this->_runQuery("TRUNCATE TABLE `hs_hr_job_application`");
  103. $this->_runQuery("TRUNCATE TABLE `hs_hr_job_application_events`");
  104. $this->_runQuery("TRUNCATE TABLE `hs_hr_job_vacancy`");
  105. $this->_runQuery("TRUNCATE TABLE `hs_hr_job_title`");
  106. $this->_runQuery("TRUNCATE TABLE `hs_hr_employee`");
  107. $this->_runQuery("DELETE FROM `hs_hr_mailnotifications`");
  108. }
  109. /**
  110. * Run given sql query, checking the return value
  111. */
  112. private function _runQuery($sql) {
  113. $this->assertTrue(mysql_query($sql), mysql_error());
  114. }
  115. /**
  116. * Test case for sendApplicationReceivedEmailToApplicant().
  117. */
  118. public function testSendApplicationReceivedEmailToApplicant() {
  119. $jobApplication = $this->jobApplications[1];
  120. $notifier = new RecruitmentMailNotifier();
  121. $mockMailer = new MockMailer();
  122. $notifier->setMailer($mockMailer);
  123. // Check successfull email
  124. $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 fail
  139. $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 email
  154. $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 fail
  183. $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 email
  203. $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 fail
  233. $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 email
  249. $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_FROM
  266. );
  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 fail
  283. $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 function
  291. */
  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(3, count($attachments));
  303. }
  304. /**
  305. * Create a JobApplication object with the passed parameters
  306. */
  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);
  314. $application->setStreet1($street1);
  315. $application->setStreet2($street2);
  316. $application->setCity($city);
  317. $application->setProvince($province);
  318. $application->setZip($zip);
  319. $application->setCountry($country);
  320. $application->setMobile($mobile);
  321. $application->setPhone($phone);
  322. $application->setEmail($email);
  323. $application->setQualifications($qualifications);
  324. return $application;
  325. }
  326. /**
  327. * Saves the given JobApplication objects in the database
  328. *
  329. * @param array $applications Array of JobApplication objects to save.
  330. */
  331. private function _createJobApplications($applications) {
  332. foreach ($applications as $application) {
  333. $sql = sprintf("INSERT INTO hs_hr_job_application(application_id, vacancy_id, firstname, middlename, ".
  334. "lastname, street1, street2, city, country_code, province, zip, " .
  335. "phone, mobile, email, qualifications) " .
  336. "VALUES(%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
  337. $application->getId(), $application->getVacancyId(), $application->getFirstName(),
  338. $application->getMiddleName(), $application->getLastName(), $application->getStreet1(),
  339. $application->getStreet2(), $application->getCity(), $application->getCountry(),
  340. $application->getProvince(), $application->getZip(), $application->getPhone(),
  341. $application->getMobile(), $application->getEmail(),
  342. $application->getQualifications());
  343. $this->assertTrue(mysql_query($sql), mysql_error());
  344. }
  345. UniqueIDGenerator::getInstance()->initTable();
  346. }
  347. /**
  348. * Retrieves the text of the template file
  349. */
  350. private function _getTemplateFile($fileName) {
  351. $text = file_get_contents(ROOT_PATH."/templates/recruitment/mails/".$fileName);
  352. return $text;
  353. }
  354. }
  355. /**
  356. * Mock class to test mailing
  357. */
  358. class MockMailer {
  359. private $text;
  360. private $subject;
  361. private $cc;
  362. private $to;
  363. private $mailType;
  364. private $attachments = array();
  365. /* result of send method*/
  366. private $result = true;
  367. public $errors = null;
  368. public function setBodyText($text) {
  369. $this->text = $text;
  370. }
  371. public function getBodyText() {
  372. return $this->text;
  373. }
  374. public function setSubject($subject) {
  375. $this->subject = $subject;
  376. }
  377. public function getSubject() {
  378. return $this->subject;
  379. }
  380. public function setCC($cc) {
  381. $this->cc = $cc;
  382. }
  383. public function getCC() {
  384. return $this->cc;
  385. }
  386. public function addTo($to) {
  387. $this->to = $to;
  388. }
  389. public function getTo() {
  390. return array($this->to);
  391. }
  392. public function setResult($result) {
  393. $this->result = $result;
  394. }
  395. public function createAttachment($attachment) {
  396. $this->attachments[] = $attachment;
  397. }
  398. public function addAttachment($attachment) {
  399. $this->attachments[] = $attachment;
  400. }
  401. public function getAttachments() {
  402. return $this->attachments;
  403. }
  404. public function send() {
  405. return $this->result;
  406. }
  407. }
  408. // Call RecruitmentMailNotifierTest::main() if this source file is executed directly.
  409. if (PHPUnit_MAIN_METHOD == "RecruitmentMailNotifierTest::main") {
  410. RecruitmentMailNotifierTest::main();
  411. }
  412. ?>