CRM-15855 - Allow mailings to be saved (but not sent) without name+subject.
[civicrm-core.git] / tests / phpunit / CiviTest / CiviUnitTestCase.php
index 895153016a6b3b35e374a4aa5b327cc40a9849aa..0fdbf562baf07545b4b72555143f13d2a47d3d85 100755 (executable)
@@ -189,11 +189,19 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     // also load the class loader
     require_once 'CRM/Core/ClassLoader.php';
     CRM_Core_ClassLoader::singleton()->register();
-    if (function_exists('_civix_phpunit_setUp')) { // FIXME: loosen coupling
+    if (function_exists('_civix_phpunit_setUp')) {
+      // FIXME: loosen coupling
       _civix_phpunit_setUp();
     }
   }
 
+  /**
+   * Override to run the test and assert its state.
+   * @return mixed
+   * @throws \Exception
+   * @throws \PHPUnit_Framework_IncompleteTest
+   * @throws \PHPUnit_Framework_SkippedTest
+   */
   protected function runTest() {
     try {
       return parent::runTest();
@@ -250,7 +258,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   /**
    * @param bool $perClass
    * @param null $object
-   * @return bool TRUE if the populate logic runs; FALSE if it is skipped
+   * @return bool
+   *   TRUE if the populate logic runs; FALSE if it is skipped
    */
   protected static function _populateDB($perClass = FALSE, &$object = NULL) {
 
@@ -554,6 +563,11 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * @match    array    Associative array of field name => expected value. Empty if asserting
    *                      that a DELETE occurred
    * @delete   boolean  True if we're checking that a DELETE action occurred.
+   * @param $daoName
+   * @param $id
+   * @param $match
+   * @param bool $delete
+   * @throws \PHPUnit_Framework_AssertionFailedError
    */
   public function assertDBState($daoName, $id, $match, $delete = FALSE) {
     if (empty($id)) {
@@ -599,8 +613,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     }
   }
 
-  // Request a record from the DB by seachColumn+searchValue. Success if a record is found.
   /**
+   * Request a record from the DB by seachColumn+searchValue. Success if a record is found.
    * @param string $daoName
    * @param $searchValue
    * @param $returnColumn
@@ -620,8 +634,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     return $value;
   }
 
-  // Request a record from the DB by seachColumn+searchValue. Success if returnColumn value is NULL.
   /**
+   * Request a record from the DB by seachColumn+searchValue. Success if returnColumn value is NULL.
    * @param string $daoName
    * @param $searchValue
    * @param $returnColumn
@@ -633,8 +647,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     $this->assertNull($value, $message);
   }
 
-  // Request a record from the DB by id. Success if row not found.
   /**
+   * Request a record from the DB by id. Success if row not found.
    * @param string $daoName
    * @param int $id
    * @param null $message
@@ -645,8 +659,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     $this->assertNull($value, $message);
   }
 
-  // Request a record from the DB by id. Success if row not found.
   /**
+   * Request a record from the DB by id. Success if row not found.
    * @param string $daoName
    * @param int $id
    * @param null $message
@@ -657,8 +671,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     $this->assertEquals($id, $value, $message);
   }
 
-  // Compare a single column value in a retrieved DB record to an expected value
   /**
+   * Compare a single column value in a retrieved DB record to an expected value
    * @param string $daoName
    * @param $searchValue
    * @param $returnColumn
@@ -666,7 +680,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * @param $expectedValue
    * @param $message
    */
-  function assertDBCompareValue(
+  public function assertDBCompareValue(
     $daoName, $searchValue, $returnColumn, $searchColumn,
     $expectedValue, $message
   ) {
@@ -674,8 +688,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     $this->assertEquals($value, $expectedValue, $message);
   }
 
-  // Compare all values in a single retrieved DB record to an array of expected values
   /**
+   * Compare all values in a single retrieved DB record to an array of expected values
    * @param string $daoName
    * @param array $searchParams
    * @param $expectedValues
@@ -697,6 +711,10 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    *
    * Example: $this->assertSql(2, 'select count(*) from foo where foo.bar like "%1"',
    * array(1 => array("Whiz", "String")));
+   * @param $expected
+   * @param $query
+   * @param array $params
+   * @param string $message
    */
   public function assertDBQuery($expected, $query, $params = array(), $message = '') {
     if ($message) {
@@ -842,6 +860,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
 
   /**
    * Check that a deleted item has been deleted
+   * @param $entity
+   * @param $id
    */
   public function assertAPIDeleted($entity, $id) {
     $this->callAPISuccess($entity, 'getcount', array('id' => $id), 0);
@@ -883,7 +903,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   }
 
   /**
-   * This function exists to wrap api functions
+   * wrap api functions
    * so we can ensure they succeed & throw exceptions without litterering the test with checks
    *
    * @param string $entity
@@ -928,12 +948,12 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * @param array $params
    * @param string $type
    *   Per http://php.net/manual/en/function.gettype.php possible types.
-   * - boolean
-   * - integer
-   * - double
-   * - string
-   * - array
-   * - object
+   *   - boolean
+   *   - integer
+   *   - double
+   *   - string
+   *   - array
+   *   - object
    *
    * @return array|int
    */
@@ -963,12 +983,12 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * @param array $params
    * @param array $checkAgainst
    *   Array to compare result against.
-   * - boolean
-   * - integer
-   * - double
-   * - string
-   * - array
-   * - object
+   *   - boolean
+   *   - integer
+   *   - double
+   *   - string
+   *   - array
+   *   - object
    *
    * @throws Exception
    * @return array|int
@@ -1005,7 +1025,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
       'debug' => 1,
     );
     $result = $this->civicrm_api($entity, 'getcount', $params);
-    if (!is_integer($result) || !empty($result['is_error']) || isset($result['values'])) {
+    if (!is_int($result) || !empty($result['is_error']) || isset($result['values'])) {
       throw new Exception('Invalid getcount result : ' . print_r($result, TRUE) . " type :" . gettype($result));
     }
     if (is_int($count)) {
@@ -1065,7 +1085,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * so the distinction between set
    * up & tested functions is clearer
    *
-   * @return array api Result
+   * @return array
+   *   api Result
    */
   public function createTestEntity() {
     return $entity = $this->callAPISuccess($this->entity, 'create', $this->params);
@@ -1074,10 +1095,13 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   /**
    * Generic function to create Organisation, to be used in test cases
    *
-   * @param array parameters for civicrm_contact_add api function call
-   * @param int sequence number if creating multiple organizations
+   * @param array $params
+   *   parameters for civicrm_contact_add api function call
+   * @param int $seq
+   *   sequence number if creating multiple organizations
    *
-   * @return int    id of Organisation created
+   * @return int
+   *   id of Organisation created
    */
   public function organizationCreate($params = array(), $seq = 0) {
     if (!$params) {
@@ -1090,10 +1114,13 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   /**
    * Generic function to create Individual, to be used in test cases
    *
-   * @param array parameters for civicrm_contact_add api function call
-   * @param int sequence number if creating multiple individuals
+   * @param array $params
+   *   parameters for civicrm_contact_add api function call
+   * @param int $seq
+   *   sequence number if creating multiple individuals
    *
-   * @return int    id of Individual created
+   * @return int
+   *   id of Individual created
    */
   public function individualCreate($params = array(), $seq = 0) {
     $params = array_merge($this->sampleContact('Individual', $seq), $params);
@@ -1103,10 +1130,13 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   /**
    * Generic function to create Household, to be used in test cases
    *
-   * @param array parameters for civicrm_contact_add api function call
-   * @param int sequence number if creating multiple households
+   * @param array $params
+   *   parameters for civicrm_contact_add api function call
+   * @param int $seq
+   *   sequence number if creating multiple households
    *
-   * @return int    id of Household created
+   * @return int
+   *   id of Household created
    */
   public function householdCreate($params = array(), $seq = 0) {
     $params = array_merge($this->sampleContact('Household', $seq), $params);
@@ -1116,10 +1146,13 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   /**
    * Helper function for getting sample contact properties
    *
-   * @param enum contact type: Individual, Organization
-   * @param int sequence number for the values of this type
+   * @param string $contact_type
+   *   enum contact type: Individual, Organization
+   * @param int $seq
+   *   sequence number for the values of this type
    *
-   * @return array   properties of sample contact (ie. $params for API call)
+   * @return array
+   *   properties of sample contact (ie. $params for API call)
    */
   public function sampleContact($contact_type, $seq = 0) {
     $samples = array(
@@ -1144,7 +1177,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     );
     $params = array('contact_type' => $contact_type);
     foreach ($samples[$contact_type] as $key => $values) {
-      $params[$key] = $values[$seq % sizeof($values)];
+      $params[$key] = $values[$seq % count($values)];
     }
     if ($contact_type == 'Individual') {
       $params['email'] = strtolower(
@@ -1164,7 +1197,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    *
    * @throws Exception
    *
-   * @return int    id of Household created
+   * @return int
+   *   id of Household created
    */
   private function _contactCreate($params) {
     $result = $this->callAPISuccess('contact', 'create', $params);
@@ -1175,25 +1209,20 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   }
 
   /**
-   * @param int $contactID
+   * Delete contact, ensuring it is not the domain contact
    *
-   * @return array|int
+   * @param int $contactID
+   *   Contact ID to delete
    */
   public function contactDelete($contactID) {
-    $params = array(
-      'id' => $contactID,
-      'skip_undelete' => 1,
-      'debug' => 1,
-    );
-    $domain = new CRM_Core_BAO_Domain;
+    $domain = new CRM_Core_BAO_Domain();
     $domain->contact_id = $contactID;
-    if ($domain->find(TRUE)) {
-      // we are finding tests trying to delete the domain contact in cleanup
-      //since this is mainly for cleanup lets put a safeguard here
-      return;
+    if (!$domain->find(TRUE)) {
+      $this->callAPISuccess('contact', 'delete', array(
+        'id' => $contactID,
+        'skip_undelete' => 1,
+      ));
     }
-    $result = $this->callAPISuccess('contact', 'delete', $params);
-    return $result;
   }
 
   /**
@@ -1202,7 +1231,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * @throws Exception
    */
   public function contactTypeDelete($contactTypeId) {
-    require_once 'CRM/Contact/BAO/ContactType.php';
     $result = CRM_Contact_BAO_ContactType::del($contactTypeId);
     if (!$result) {
       throw new Exception('Could not delete contact type');
@@ -1277,7 +1305,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   public function membershipDelete($membershipID) {
     $deleteParams = array('id' => $membershipID);
     $result = $this->callAPISuccess('Membership', 'Delete', $deleteParams);
-    return;
   }
 
   /**
@@ -1305,7 +1332,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
       return;
     }
     $result = $this->callAPISuccess('MembershipStatus', 'Delete', array('id' => $membershipStatusID));
-    return;
   }
 
   /**
@@ -1371,7 +1397,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * @param array $params
    *   Array of contact id and event id values.
    *
-   * @return int $id of participant created
+   * @return int
+   *   $id of participant created
    */
   public function participantCreate($params) {
     if (empty($params['contact_id'])) {
@@ -1398,7 +1425,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   /**
    * Create Payment Processor
    *
-   * @return object of Payment Processsor
+   * @return CRM_Financial_DAO_PaymentProcessor
+   *   instance of Payment Processsor
    */
   public function processorCreate() {
     $processorParams = array(
@@ -1420,7 +1448,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * Create contribution page
    *
    * @param array $params
-   * @return object of contribution page
+   * @return array
+   *   Array of contribution page
    */
   public function contributionPageCreate($params) {
     $this->_pageParams = array(
@@ -1442,7 +1471,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * Create Tag
    *
    * @param array $params
-   * @return array result of created tag
+   * @return array
+   *   result of created tag
    */
   public function tagCreate($params = array()) {
     $defaults = array(
@@ -1460,6 +1490,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    *
    * @param int $tagId
    *   Id of the tag to be deleted.
+   *
+   * @return int
    */
   public function tagDelete($tagId) {
     require_once 'api/api.php';
@@ -1488,7 +1520,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * @param int $cID
    *   Contact_id.
    *
-   * @return int id of created contribution
+   * @return int
+   *   id of created contribution
    */
   public function pledgeCreate($cID) {
     $params = array(
@@ -1529,12 +1562,13 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    *   Contact_id.
    * @param int $cTypeID
    *   Id of financial type.
-   *
    * @param int $invoiceID
    * @param int $trxnID
    * @param int $paymentInstrumentID
    * @param bool $isFee
-   * @return int id of created contribution
+   *
+   * @return int
+   *   id of created contribution
    */
   public function contributionCreate($cID, $cTypeID = 1, $invoiceID = 67890, $trxnID = 12345, $paymentInstrumentID = 1, $isFee = TRUE) {
     $params = array(
@@ -1567,10 +1601,11 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * @param array $params
    * @param int $financialType
    *   Id of financial type.
-   *
    * @param int $invoiceID
    * @param int $trxnID
-   * @return int id of created contribution
+   *
+   * @return int
+   *   id of created contribution
    */
   public function onlineContributionCreate($params, $financialType, $invoiceID = 67890, $trxnID = 12345) {
     $contribParams = array(
@@ -1610,7 +1645,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * @param array $params
    *   Name-value pair for an event.
    *
-   * @return array $event
+   * @return array
    */
   public function eventCreate($params = array()) {
     // if no contact was passed, make up a dummy event creator
@@ -1678,7 +1713,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    *
    * @param int $participantID
    * @param int $contributionID
-   * @return int $id of created payment
+   * @return int
+   *   $id of created payment
    */
   public function participantPaymentCreate($participantID, $contributionID = NULL) {
     //Create Participant Payment record With Values
@@ -1707,7 +1743,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * Add a Location
    *
    * @param int $contactID
-   * @return int location id of created location
+   * @return int
+   *   location id of created location
    */
   public function locationAdd($contactID) {
     $address = array(
@@ -1748,7 +1785,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * Add a Location Type
    *
    * @param array $params
-   * @return CRM_Core_DAO_LocationType location id of created location
+   * @return CRM_Core_DAO_LocationType
+   *   location id of created location
    */
   public function locationTypeCreate($params = NULL) {
     if ($params === NULL) {
@@ -1772,7 +1810,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   /**
    * Delete a Location Type
    *
-   * @param int location type id
+   * @param int $locationTypeId
    */
   public function locationTypeDelete($locationTypeId) {
     $locationType = new CRM_Core_DAO_LocationType();
@@ -1784,7 +1822,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * Add a Group
    *
    * @param array $params
-   * @return int groupId of created group
+   * @return int
+   *   groupId of created group
    */
   public function groupCreate($params = array()) {
     $params = array_merge(array(
@@ -1810,8 +1849,10 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    *
    * @params array to add group
    *
-   * @param array $params
-   * @return int groupId of created group
+   * @param int $groupID
+   * @param int $totalCount
+   * @return int
+   *    groupId of created group
    */
   public function groupContactCreate($groupID, $totalCount = 10) {
     $params = array('group_id' => $groupID);
@@ -1866,7 +1907,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * Add a UF Join Entry
    *
    * @param array $params
-   * @return int $id of created UF Join
+   * @return int
+   *   $id of created UF Join
    */
   public function ufjoinCreate($params = NULL) {
     if ($params === NULL) {
@@ -1886,7 +1928,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   /**
    * Delete a UF Join Entry
    *
-   * @param array with missing uf_group_id
+   * @param array $params
+   *   with missing uf_group_id
    */
   public function ufjoinDelete($params = NULL) {
     if ($params === NULL) {
@@ -1978,10 +2021,10 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    *
    * @param array $params
    *   Parameters.
+   * @return array
    */
   public function activityTypeCreate($params) {
-    $result = $this->callAPISuccess('ActivityType', 'create', $params);
-    return $result;
+    return $this->callAPISuccess('ActivityType', 'create', $params);
   }
 
   /**
@@ -1989,11 +2032,11 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    *
    * @param int $activityTypeId
    *   Id of the activity type.
+   * @return array
    */
   public function activityTypeDelete($activityTypeId) {
     $params['activity_type_id'] = $activityTypeId;
-    $result = $this->callAPISuccess('ActivityType', 'delete', $params);
-    return $result;
+    return $this->callAPISuccess('ActivityType', 'delete', $params);
   }
 
   /**
@@ -2019,9 +2062,9 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
 
     //have a crack @ deleting it first in the hope this will prevent derailing our tests
     $this->callAPISuccess('custom_group', 'get', array(
-        'title' => $params['title'],
-        array('api.custom_group.delete' => 1),
-      ));
+      'title' => $params['title'],
+      array('api.custom_group.delete' => 1),
+    ));
 
     return $this->callAPISuccess('custom_group', 'create', $params);
   }
@@ -2029,6 +2072,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   /**
    * Existing function doesn't allow params to be over-ridden so need a new one
    * this one allows you to only pass in the params you want to change
+   * @param array $params
+   * @return array|int
    */
   public function CustomGroupCreateByParams($params = array()) {
     $defaults = array(
@@ -2044,6 +2089,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
 
   /**
    * Create custom group with multi fields
+   * @param array $params
+   * @return array|int
    */
   public function CustomGroupMultipleCreateByParams($params = array()) {
     $defaults = array(
@@ -2056,6 +2103,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
 
   /**
    * Create custom group with multi fields
+   * @param array $params
+   * @return array
    */
   public function CustomGroupMultipleCreateWithFields($params = array()) {
     // also need to pass on $params['custom_field'] if not set but not in place yet
@@ -2064,24 +2113,24 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     $ids['custom_group_id'] = $customGroup['id'];
 
     $customField = $this->customFieldCreate(array(
-        'custom_group_id' => $ids['custom_group_id'],
-        'label' => 'field_1' . $ids['custom_group_id'],
-      ));
+      'custom_group_id' => $ids['custom_group_id'],
+      'label' => 'field_1' . $ids['custom_group_id'],
+    ));
 
     $ids['custom_field_id'][] = $customField['id'];
 
     $customField = $this->customFieldCreate(array(
-        'custom_group_id' => $ids['custom_group_id'],
-        'default_value' => '',
-        'label' => 'field_2' . $ids['custom_group_id'],
-      ));
+      'custom_group_id' => $ids['custom_group_id'],
+      'default_value' => '',
+      'label' => 'field_2' . $ids['custom_group_id'],
+    ));
     $ids['custom_field_id'][] = $customField['id'];
 
     $customField = $this->customFieldCreate(array(
-        'custom_group_id' => $ids['custom_group_id'],
-        'default_value' => '',
-        'label' => 'field_3' . $ids['custom_group_id'],
-      ));
+      'custom_group_id' => $ids['custom_group_id'],
+      'default_value' => '',
+      'label' => 'field_3' . $ids['custom_group_id'],
+    ));
     $ids['custom_field_id'][] = $customField['id'];
 
     return $ids;
@@ -2093,10 +2142,11 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    *
    * @param string $function
    *   __FUNCTION__.
-   * @param $filename
-   *   String $file __FILE__.
+   * @param string $filename
+   *   $file __FILE__.
    *
-   * @return array $ids ids of created objects
+   * @return array
+   *   ids of created objects
    */
   public function entityCustomGroupWithSingleFieldCreate($function, $filename) {
     $params = array('title' => $function);
@@ -2126,7 +2176,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    *
    * @param array $params
    *   (custom_group_id) is required.
-   * @return array|int
+   * @return array
    */
   public function customFieldCreate($params) {
     $params = array_merge(array(
@@ -2139,13 +2189,10 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     ), $params);
 
     $result = $this->callAPISuccess('custom_field', 'create', $params);
-
-    if ($result['is_error'] == 0 && isset($result['id'])) {
-      CRM_Core_BAO_CustomField::getTableColumnGroup($result['id'], 1);
-      // force reset of enabled components to help grab custom fields
-      CRM_Core_Component::getEnabledComponents(1);
-      return $result;
-    }
+    // these 2 functions are called with force to flush static caches
+    CRM_Core_BAO_CustomField::getTableColumnGroup($result['id'], 1);
+    CRM_Core_Component::getEnabledComponents(1);
+    return $result;
   }
 
   /**
@@ -2165,7 +2212,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * Create note
    *
    * @param int $cId
-   * @return array $note
+   * @return array
    */
   public function noteCreate($cId) {
     $params = array(
@@ -2320,7 +2367,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * and debug related fields are unset
    *
    * @param array $result
-   *
    */
   public function tidyExampleResult(&$result) {
     if (!is_array($result)) {
@@ -2459,11 +2505,13 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
         return TRUE;
       }
     }
+    return FALSE;
   }
 
   /**
    * @param $tablesToTruncate
    * @param bool $dropCustomValueTables
+   * @throws \Exception
    */
   public function quickCleanup($tablesToTruncate, $dropCustomValueTables = FALSE) {
     if ($this->tx) {
@@ -2551,7 +2599,6 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
    *   Should the entity be deleted as part of this check.
    * @param string $errorText
    *   Text to print on error.
-   *
    */
   /**
    * @param array $params
@@ -2629,7 +2676,6 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
    *   Actual calculated values.
    * @param array $expected
    *   Expected values.
-   *
    */
   public function checkArrayEquals(&$actual, &$expected) {
     self::unsetId($actual);
@@ -2641,7 +2687,6 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
    * Unset the key 'id' from the array
    * @param array $unformattedArray
    *   The array from which the 'id' has to be unset.
-   *
    */
   public static function unsetId(&$unformattedArray) {
     $formattedArray = array();
@@ -2703,7 +2748,7 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
    * Generate a temporary folder
    *
    * @param string $prefix
-   * @return string $string
+   * @return string
    */
   public function createTempDir($prefix = 'test-') {
     $tempDir = CRM_Utils_File::tempdir($prefix);
@@ -2725,6 +2770,7 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
 
   /**
    * Temporarily replace the singleton extension with a different one
+   * @param \CRM_Extension_System $system
    */
   public function setExtensionSystem(CRM_Extension_System $system) {
     if ($this->origExtensionSystem == NULL) {
@@ -2959,7 +3005,6 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
    *  $this->createLoggedInUser();
    *   $this->_permissionedDisabledGroup = $this->groupCreate(array('title' => 'pick-me-disabled', 'is_active' => 0, 'name' => 'pick-me-disabled'));
    *   $this->_permissionedGroup = $this->groupCreate(array('title' => 'pick-me-active', 'is_active' => 1, 'name' => 'pick-me-active'));
-   *
    */
   public function setupACL() {
     global $_REQUEST;
@@ -3022,24 +3067,24 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
     $contributionPriceSet = $this->callAPISuccess('price_set', 'getsingle', array('name' => 'default_contribution_amount'));
     $firstID = $contributionPriceSet['id'];
     $this->callAPISuccess('price_set', 'create', array(
-        'id' => $contributionPriceSet['id'],
-        'is_active' => 0,
-        'name' => 'old',
-      ));
+      'id' => $contributionPriceSet['id'],
+      'is_active' => 0,
+      'name' => 'old',
+    ));
     unset($contributionPriceSet['id']);
     $newPriceSet = $this->callAPISuccess('price_set', 'create', $contributionPriceSet);
     $priceField = $this->callAPISuccess('price_field', 'getsingle', array(
-        'price_set_id' => $firstID,
-        'options' => array('limit' => 1),
-      ));
+      'price_set_id' => $firstID,
+      'options' => array('limit' => 1),
+    ));
     unset($priceField['id']);
     $priceField['price_set_id'] = $newPriceSet['id'];
     $newPriceField = $this->callAPISuccess('price_field', 'create', $priceField);
     $priceFieldValue = $this->callAPISuccess('price_field_value', 'getsingle', array(
-        'price_set_id' => $firstID,
-        'sequential' => 1,
-        'options' => array('limit' => 1),
-      ));
+      'price_set_id' => $firstID,
+      'sequential' => 1,
+      'options' => array('limit' => 1),
+    ));
 
     unset($priceFieldValue['id']);
     //create some padding to use up ids
@@ -3054,6 +3099,8 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
    * this parent class & we don't have a structure for that yet
    * There is another function to this effect on the PaypalPro test but it appears to be silently failing
    * & the best protection agains that is the functions this class affords
+   * @param array $params
+   * @return int $result['id'] payment processor id
    */
   public function paymentProcessorCreate($params = array()) {
     $params = array_merge(array(
@@ -3142,18 +3189,18 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
       'line_total' => 200,
       'financial_type_id' => 1,
       'price_field_id' => $this->callAPISuccess('price_field', 'getvalue', array(
-          'return' => 'id',
-          'label' => 'Membership Amount',
-        )),
+        'return' => 'id',
+        'label' => 'Membership Amount',
+      )),
       'price_field_value_id' => $this->callAPISuccess('price_field_value', 'getvalue', array(
-          'return' => 'id',
-          'label' => 'General',
-        )),
+        'return' => 'id',
+        'label' => 'General',
+      )),
     ));
     $this->callAPISuccess('membership_payment', 'create', array(
-        'contribution_id' => $this->_contributionID,
-        'membership_id' => $this->ids['membership'],
-      ));
+      'contribution_id' => $this->_contributionID,
+      'membership_id' => $this->ids['membership'],
+    ));
   }
 
   /**
@@ -3222,4 +3269,5 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
       ob_end_clean();
     }
   }
+
 }