/**
  * Test case for sendSeekApprovalToDirector().
  */
 public function testSendSeekApprovalToDirector()
 {
     $jobApplication = JobApplication::getJobApplication(2);
     $event = $jobApplication->getEventOfType(JobApplicationEvent::EVENT_SEEK_APPROVAL);
     $notifier = new RecruitmentMailNotifier();
     $mockMailer = new MockMailer();
     $notifier->setMailer($mockMailer);
     // Check successfull email
     $result = $notifier->sendSeekApprovalToDirector($jobApplication, $event);
     $this->assertTrue($result);
     $notifier->setMailer($mockMailer);
     $to = $mockMailer->getTo();
     $this->assertEquals(1, count($to));
     $this->assertEquals('*****@*****.**', $to[0]);
     $subject = $this->_getTemplateFile(RecruitmentMailNotifier::SUBJECT_SEEK_APPROVAL_DIRECTOR);
     $body = $this->_getTemplateFile(RecruitmentMailNotifier::TEMPLATE_SEEK_APPROVAL_DIRECTOR);
     $search = array(RecruitmentMailNotifier::VARIABLE_JOB_TITLE, RecruitmentMailNotifier::VARIABLE_TO, RecruitmentMailNotifier::VARIABLE_APPLICANT_FIRSTNAME, RecruitmentMailNotifier::VARIABLE_APPLICANT_MIDDLENAME, RecruitmentMailNotifier::VARIABLE_APPLICANT_LASTNAME, RecruitmentMailNotifier::VARIABLE_APPLICANT_STREET1, RecruitmentMailNotifier::VARIABLE_APPLICANT_STREET2, RecruitmentMailNotifier::VARIABLE_APPLICANT_CITY, RecruitmentMailNotifier::VARIABLE_APPLICANT_PROVINCE, RecruitmentMailNotifier::VARIABLE_APPLICANT_ZIP, RecruitmentMailNotifier::VARIABLE_APPLICANT_COUNTRY, RecruitmentMailNotifier::VARIABLE_APPLICANT_PHONE, RecruitmentMailNotifier::VARIABLE_APPLICANT_MOBILE, RecruitmentMailNotifier::VARIABLE_APPLICANT_EMAIL, RecruitmentMailNotifier::VARIABLE_APPLICANT_QUALIFICATIONS, RecruitmentMailNotifier::VARIABLE_SEEK_NOTES, RecruitmentMailNotifier::VARIABLE_FROM);
     $replace = array('Driver', 'John', $jobApplication->getFirstName(), $jobApplication->getMiddleName(), $jobApplication->getLastName(), $jobApplication->getStreet1(), $jobApplication->getStreet2(), $jobApplication->getCity(), $jobApplication->getProvince(), $jobApplication->getZip(), 'England', $jobApplication->getPhone(), $jobApplication->getMobile(), $jobApplication->getEmail(), $jobApplication->getQualifications(), $event->getNotes(), 'Saman Rajasinghe');
     $body = str_replace($search, $replace, $body);
     $subject = str_replace($search, $replace, $subject);
     $subject = str_replace(array("\r", "\n"), array("", ""), $subject);
     $this->assertEquals($subject, $mockMailer->getSubject());
     $this->assertEquals($body, $mockMailer->getBodyText());
     // without to email address - should fail
     $this->_runQuery("UPDATE hs_hr_employee SET emp_work_email=NULL where emp_number = 13");
     $mockMailer = new MockMailer();
     $notifier->setMailer($mockMailer);
     $result = $notifier->sendSeekApprovalToDirector($jobApplication, $event);
     $this->assertFalse($result);
 }
예제 #2
0
 private function _seekApproval($event)
 {
     if ($this->authorizeObj->isAdmin() || $this->authorizeObj->isManager() || $this->authorizeObj->isOfferer()) {
         // TODO: Validate if Hiring manager or interview manager and in correct status
         $application = JobApplication::getJobApplication($event->getApplicationId());
         $application->setStatus(JobApplication::STATUS_PENDING_APPROVAL);
         try {
             $application->save();
             $event->setEventType(JobApplicationEvent::EVENT_SEEK_APPROVAL);
             $event->setCreatedBy($_SESSION['user']);
             $event->save();
             // Send notification to Interviewer
             $notifier = new RecruitmentMailNotifier();
             $mailResult = $notifier->sendSeekApprovalToDirector($application, $event);
             $message = 'UPDATE_SUCCESS';
         } catch (Exception $e) {
             $message = 'UPDATE_FAILURE';
         }
         $this->redirect($message, '?recruitcode=Application&action=List');
     } else {
         $this->_notAuthorized();
     }
 }