<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
* Mail utils for use during unit testing to allow retrieval
protected $_webtest = FALSE;
/**
- * Constructor
+ * Constructor.
*
* @param CiviSeleniumTestCase|CiviUnitTestCase $unit_test The currently running test
- * @param bool $startImmediately Start writing to db now or wait until start() is called
+ * @param bool $startImmediately
+ * Start writing to db now or wait until start() is called.
*/
- function __construct(&$unit_test, $startImmediately = TRUE) {
+ public function __construct(&$unit_test, $startImmediately = TRUE) {
$this->_ut = $unit_test;
// Check if running under webtests or not
}
/**
- * Start writing emails to db instead of current option
+ * Start writing emails to db instead of current option.
*/
- function start() {
+ public function start() {
if ($this->_webtest) {
// Change outbound mail setting
$this->_ut->openCiviPage('admin/setting/smtp', "reset=1", "_qf_Smtp_next");
}
}
- function stop() {
+ public function stop() {
if ($this->_webtest) {
if ($this->_outBound_option != CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB) {
// Change outbound mail setting
*
* @return ezcMail|string
*/
- function getMostRecentEmail($type = 'raw') {
+ public function getMostRecentEmail($type = 'raw') {
$msg = '';
if ($this->_webtest) {
case 'raw':
// nothing to do
break;
+
case 'ezc':
$msg = $this->convertToEzc($msg);
break;
}
/**
- * @param string $type 'raw'|'ezc'
+ * @param string $type
+ * 'raw'|'ezc'.
*
* @throws Exception
* @return array(ezcMail)|array(string)
*/
- function getAllMessages($type = 'raw') {
+ public function getAllMessages($type = 'raw') {
$msgs = array();
if ($this->_webtest) {
case 'raw':
// nothing to do
break;
+
case 'ezc':
foreach ($msgs as $i => $msg) {
$msgs[$i] = $this->convertToEzc($msg);
/**
* @return int
*/
- function getSelectedOutboundOption() {
+ public function getSelectedOutboundOption() {
$selectedOption = CRM_Mailing_Config::OUTBOUND_OPTION_MAIL;
// Is there a better way to do this? How do you get the currently selected value of a radio button in selenium?
for ($i = 0; $i <= 5; $i++) {
*/
/**
- * Check contents of mail log
+ * Check contents of mail log.
*
- * @param array $strings strings that should be included
- * @param array $absentStrings strings that should not be included
+ * @param array $strings
+ * Strings that should be included.
+ * @param array $absentStrings
+ * Strings that should not be included.
* @param string $prefix
*
* @return \ezcMail|string
*/
- function checkMailLog($strings, $absentStrings = array(), $prefix = '') {
+ public function checkMailLog($strings, $absentStrings = array(), $prefix = '') {
$mail = $this->getMostRecentEmail('raw');
foreach ($strings as $string) {
$this->_ut->assertContains($string, $mail, "$string . not found in $mail $prefix");
}
foreach ($absentStrings as $string) {
- $this->_ut->assertEmpty(strstr($mail, $string), "$string incorrectly found in $mail $prefix");
- ;
+ $this->_ut->assertEmpty(strstr($mail, $string), "$string incorrectly found in $mail $prefix");;
}
return $mail;
}
/**
- * Check that mail log is empty
+ * Check that mail log is empty.
+ * @param string $prefix
*/
- function assertMailLogEmpty($prefix = '') {
+ public function assertMailLogEmpty($prefix = '') {
$mail = $this->getMostRecentEmail('raw');
$this->_ut->assertEmpty($mail, 'mail sent when it should not have been ' . $prefix);
}
/**
* Assert that $expectedRecipients (and no else) have received emails
*
- * @param array $expectedRecipients array($msgPos => array($recipPos => $emailAddr))
+ * @param array $expectedRecipients
+ * Array($msgPos => array($recipPos => $emailAddr)).
*/
- function assertRecipients($expectedRecipients) {
+ public function assertRecipients($expectedRecipients) {
$recipients = array();
foreach ($this->getAllMessages('ezc') as $message) {
$recipients[] = CRM_Utils_Array::collect('email', $message->to);
}
/**
- * Remove any sent messages from the log
+ * Remove any sent messages from the log.
*/
- function clearMessages() {
+ public function clearMessages() {
if ($this->_webtest) {
throw new Exception("Not implementated: clearMessages for WebTest");
}
}
/**
- * @param string $msg email header and body
+ * @param string $msg
+ * Email header and body.
* @return ezcMail
*/
private function convertToEzc($msg) {
$this->_ut->assertNotEmpty($mail, 'Cannot parse mail');
return $mail[0];
}
+
}