Merge branch 'CRM-13067-bao-prep' of https://github.com/eileenmcnaughton/civicrm...
[civicrm-core.git] / tests / phpunit / CiviTest / CiviUnitTestCase.php
index 3ac7ec955376dac03d96a6967447a87e181a4e0f..59c8493be5c2f8acdcd82ab831f63a4b60e0e1c5 100644 (file)
@@ -1567,7 +1567,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   function activityCreate($params = NULL) {
 
     if ($params === NULL) {
-      $individualSourceID = $this->individualCreate(NULL);
+      $individualSourceID = $this->individualCreate();
 
       $contactParams = array(
         'first_name' => 'Julia',
@@ -1928,6 +1928,11 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
       'scheduled_date' => '20130728085413',
       'approval_date' => '20130728085413',
       'pledge_start_date_high' => '20130726090416',
+      'start_date' => '2013-07-29 00:00:00',
+      'event_start_date' => '2013-07-29 00:00:00',
+      'end_date' => '2013-08-04 00:00:00',
+      'event_end_date' => '2013-08-04 00:00:00',
+      'decision_date' => '20130805000000',
     );
 
     $keysToUnset = array('xdebug', 'undefined_fields',);
@@ -1936,9 +1941,20 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
         unset($result[$unwantedKey]);
       }
     }
+    if (isset($result['values'])) {
+      if(!is_array($result['values'])) {
+        return;
+      }
+      $resultArray = &$result['values'];
+    }
+    elseif(is_array($result)) {
+      $resultArray = &$result;
+    }
+    else {
+      return;
+    }
 
-    if (isset($result['values']) && is_array($result['values'])) {
-      foreach ($result['values'] as $index => &$values) {
+    foreach ($resultArray as $index => &$values) {
         if(!is_array($values)) {
           continue;
         }
@@ -1958,11 +1974,10 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
           if(in_array($key, $keysToUnset)) {
             unset($values[$key]);
           }
-          if(array_key_exists($key, $fieldsToChange)) {
+          if(array_key_exists($key, $fieldsToChange) && !empty($value)) {
             $value = $fieldsToChange[$key];
           }
         }
-      }
     }
   }