X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FDAO.php;h=2e0f4ab65ac58951238b913b109b1b8de487d65c;hb=fd96067165316831b50e48972059930ad1785444;hp=b3517d59f9b0eb90df33fabb68f5d4f7775d049a;hpb=a755b1785b561f65aca4115b3c81209c2816435d;p=civicrm-core.git diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index b3517d59f9..2e0f4ab65a 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1264,6 +1264,11 @@ SELECT contact_id $numObjects = 1, $createOnly = FALSE ) { + //this is a test function also backtrace is set for the test suite it sometimes unsets itself + // so we re-set here in case + $config = CRM_Core_Config::singleton(); + $config->backtrace = TRUE; + static $counter = 0; CRM_Core_DAO::$_testEntitiesToSkip = array( 'CRM_Core_DAO_Worldregion', @@ -1295,6 +1300,10 @@ SELECT contact_id //skip the FK if it is not required // if it's contact id we should create even if not required // we'll have a go @ fetching first though + // we WILL create campaigns though for so tests with a campaign pseudoconstant will complete + if($FKClassName === 'CRM_Campaign_DAO_Campaign' && $daoName != $FKClassName) { + $required = TRUE; + } if (!$required && $dbName != 'contact_id') { $fkDAO = new $FKClassName; if($fkDAO->find(TRUE)){ @@ -1348,7 +1357,12 @@ SELECT contact_id case CRM_Utils_Type::T_DATE: case CRM_Utils_Type::T_TIMESTAMP: + case CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME: $object->$dbName = '19700101'; + if($dbName == 'end_date') { + // put this in the future + $object->$dbName = '20200101'; + } break; case CRM_Utils_Type::T_TIME: @@ -1418,8 +1432,12 @@ SELECT contact_id static function deleteTestObjects($daoName, $params = array( )) { + //this is a test function also backtrace is set for the test suite it sometimes unsets itself + // so we re-set here in case + $config = CRM_Core_Config::singleton(); + $config->backtrace = TRUE; - $object = new $daoName ( ); + $object = new $daoName(); $object->id = CRM_Utils_Array::value('id', $params); $deletions = array(); // array(array(0 => $daoName, 1 => $daoParams)) @@ -1797,7 +1815,7 @@ EOS; public function getOptionLabels() { $fields = $this->fields(); if ($fields === NULL) { - throw new exception ('Cannot call getOptionLabels on CRM_Core_DAO'); + throw new Exception ('Cannot call getOptionLabels on CRM_Core_DAO'); } foreach ($fields as $field) { $name = CRM_Utils_Array::value('name', $field); @@ -1826,7 +1844,7 @@ EOS; ); // Validation: enforce uniformity of this param if ($context !== NULL && !isset($contexts[$context])) { - throw new exception("'$context' is not a valid context for buildOptions."); + throw new Exception("'$context' is not a valid context for buildOptions."); } return $contexts; } @@ -1876,7 +1894,7 @@ EOS; case 'BETWEEN': case 'NOT BETWEEN': if (empty($criteria[0]) || empty($criteria[1])) { - throw new exception("invalid criteria for $operator"); + throw new Exception("invalid criteria for $operator"); } if(!$returnSanitisedArray) { return (sprintf('%s ' . $operator . ' "%s" AND "%s"', $fieldName, CRM_Core_DAO::escapeString($criteria[0]), CRM_Core_DAO::escapeString($criteria[1]))); @@ -1890,7 +1908,7 @@ EOS; case 'IN': case 'NOT IN': if (empty($criteria)) { - throw new exception("invalid criteria for $operator"); + throw new Exception("invalid criteria for $operator"); } $escapedCriteria = array_map(array( 'CRM_Core_DAO', @@ -1946,4 +1964,6 @@ EOS; return substr($string, 0, $length - 8) . "_{$md5string}"; } + function setApiFilter(&$params) {} + }