+--------------------------------------------------------------------+
| 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.
*/
public function __construct(&$unit_test, $startImmediately = TRUE) {
$this->_ut = $unit_test;
}
/**
- * Start writing emails to db instead of current option
+ * Start writing emails to db instead of current option.
*/
public function start() {
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)
case 'raw':
// nothing to do
break;
+
case 'ezc':
foreach ($msgs as $i => $msg) {
$msgs[$i] = $this->convertToEzc($msg);
*/
/**
- * 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
$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
*/
public function assertMailLogEmpty($prefix = '') {
$mail = $this->getMostRecentEmail('raw');
/**
* 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)).
*/
public function assertRecipients($expectedRecipients) {
$recipients = array();
}
/**
- * Remove any sent messages from the log
+ * Remove any sent messages from the log.
*/
public function clearMessages() {
if ($this->_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];
}
+
}