Merge pull request #5127 from monishdeb/CRM-14114
[civicrm-core.git] / tests / phpunit / CiviTest / CiviMailUtils.php
index d8d77caadb22da4ad4f632be612fea0c87ceb9ad..c40e0c707b39960c00c35b65483281da7292982a 100644 (file)
@@ -22,7 +22,7 @@
  | 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
@@ -59,10 +59,11 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
   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;
@@ -78,7 +79,7 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
   }
 
   /**
-   * Start writing emails to db instead of current option
+   * Start writing emails to db instead of current option.
    */
   public function start() {
     if ($this->_webtest) {
@@ -180,6 +181,7 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
       case 'raw':
         // nothing to do
         break;
+
       case 'ezc':
         $msg = $this->convertToEzc($msg);
         break;
@@ -188,7 +190,8 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
   }
 
   /**
-   * @param string $type 'raw'|'ezc'
+   * @param string $type
+   *   'raw'|'ezc'.
    *
    * @throws Exception
    * @return array(ezcMail)|array(string)
@@ -211,6 +214,7 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
       case 'raw':
         // nothing to do
         break;
+
       case 'ezc':
         foreach ($msgs as $i => $msg) {
           $msgs[$i] = $this->convertToEzc($msg);
@@ -244,10 +248,12 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
    */
 
   /**
-   * 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
@@ -258,14 +264,14 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
       $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');
@@ -275,7 +281,8 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
   /**
    * 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();
@@ -292,7 +299,7 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
   }
 
   /**
-   * Remove any sent messages from the log
+   * Remove any sent messages from the log.
    */
   public function clearMessages() {
     if ($this->_webtest) {
@@ -304,7 +311,8 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
   }
 
   /**
-   * @param string $msg email header and body
+   * @param string $msg
+   *   Email header and body.
    * @return ezcMail
    */
   private function convertToEzc($msg) {
@@ -314,4 +322,5 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
     $this->_ut->assertNotEmpty($mail, 'Cannot parse mail');
     return $mail[0];
   }
+
 }