Merge pull request #2714 from jitendrapurohit/CRMTestFix
[civicrm-core.git] / api / v3 / examples / Activity / DateTimeHigh.php
index a280514f0bbf6a2d8d6630afbd133faf0861d754..f31c76d95faec5801e8a02598ac0d25211a3147b 100644 (file)
@@ -1,35 +1,43 @@
 <?php
-
-/*
- demonstrates _high filter (at time of writing doesn't work if contact_id is set
+/**
+ * Test Generated example of using activity get API
+ * demonstrates _high filter (at time of writing doesn't work if contact_id is set *
  */
 function activity_get_example(){
-$params = array( 
-  'source_contact_id' => 17,
-  'version' => 3,
+$params = array(
+  'source_contact_id' => 1,
   'filter.activity_date_time_high' => '20120101000000',
   'sequential' => 1,
 );
 
-  $result = civicrm_api( 'activity','get',$params );
+try{
+  $result = civicrm_api3('activity', 'get', $params);
+}
+catch (CiviCRM_API3_Exception $e) {
+  // handle error here
+  $errorMessage = $e->getMessage();
+  $errorCode = $e->getErrorCode();
+  $errorData = $e->getExtraParams();
+  return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function activity_get_expectedresult(){
 
-  $expectedResult = array( 
+  $expectedResult = array(
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
   'id' => 1,
-  'values' => array( 
-      '0' => array( 
+  'values' => array(
+      '0' => array(
           'id' => '1',
-          'activity_type_id' => '44',
+          'activity_type_id' => '46',
           'subject' => 'Make-it-Happen Meeting',
           'activity_date_time' => '2011-01-01 00:00:00',
           'duration' => '120',
@@ -41,12 +49,12 @@ function activity_get_expectedresult(){
           'is_auto' => 0,
           'is_current_revision' => '1',
           'is_deleted' => 0,
-          'source_contact_id' => '17',
+          'source_contact_id' => '1',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
@@ -54,20 +62,20 @@ function activity_get_expectedresult(){
 * This example has been generated from the API test suite. The test that created it is called
 *
 * testGetFilterMaxDate and can be found in
-* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ActivityTest.php
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
 *
 * You can see the outcome of the API tests at
-* http://tests.dev.civicrm.org/trunk/results-api_v3
+* https://test.civicrm.org/job/CiviCRM-master-git/
 *
 * To Learn about the API read
-* http://book.civicrm.org/developer/current/techniques/api/
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
 *
-* and review the wiki at
-* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api/explorer
 *
 * Read more about testing here
 * http://wiki.civicrm.org/confluence/display/CRM/Testing
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/