/** * Notify admin about suite failure * * @param $report string Full suite text report * @return void * @see runSuite() * @throws phpRack_Exception * @todo Now we work only with one notifier, which is in class phpRack_Mail. Later * we should add other notifiers, like SMS, IRC, ICQ, etc. When we add them we * should move our phpRack_Mail class to phpRack_Notifier_Mail and create other * notifiers there. */ protected function _notifyAboutFailure($report) { // no notification required if (empty($this->_options['notify'])) { return; } if (!is_array($this->_options['notify'])) { throw new phpRack_Exception("Parameter 'notify' should be an array, '{$this->_options['notify']}' given"); } if (array_key_exists('email', $this->_options['notify'])) { /** * @see phpRack_Adapters_Notifier_Mail */ require_once PHPRACK_PATH . '/Adapters/Notifier/Mail.php'; if (array_key_exists('transport', $this->_options['notify']['email'])) { $transport = $this->_options['notify']['email']['transport']; } else { $transport = array(); } if (!empty($transport['class'])) { $class = $transport['class']; unset($transport['class']); } else { $class = 'sendmail'; } $mail = phpRack_Adapters_Notifier_Mail::factory($class, $transport); $mail->setSubject('phpRack Suite Failure' . (isset($this->_options['notify']['title']) ? ' at ' . $this->_options['notify']['title'] : false)); $mail->setBody($report); /** * @todo Only one recipient is supported now */ $mail->setTo($this->_options['notify']['email']['recipients']); $mail->send(); } }
public function testMailFactorySendmail() { $mail = phpRack_Adapters_Notifier_Mail::factory(); $this->assertTrue($mail instanceof phpRack_Adapters_Notifier_Mail_Sendmail); }