Merge pull request #2714 from jitendrapurohit/CRMTestFix
[civicrm-core.git] / api / v3 / examples / Survey / ChainedGetDelete.php
index 28e453667fd5924d28c4bec7fae1da7782a8fefd..21e9c3413761d5a0877d810c1cb8c2f478670950 100644 (file)
@@ -1,22 +1,29 @@
 <?php
-
-/*
- demonstrates get + delete in the same call
+/**
+ * Test Generated example of using survey get API
+ * demonstrates get + delete in the same call *
  */
 function survey_get_example(){
 $params = array(
   'title' => 'survey title',
   'api.survey.delete' => 1,
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $result = civicrm_api( 'survey','get',$params );
+try{
+  $result = civicrm_api3('survey', '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 survey_get_expectedresult(){
@@ -35,8 +42,9 @@ function survey_get_expectedresult(){
           'max_number_of_contacts' => '12',
           'is_active' => '1',
           'is_default' => 0,
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 08:49:19',
           'bypass_confirm' => 0,
+          'is_share' => '1',
           'api.survey.delete' => array(
               'is_error' => 0,
               'version' => 3,
@@ -47,7 +55,7 @@ function survey_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
@@ -55,20 +63,20 @@ function survey_get_expectedresult(){
 * This example has been generated from the API test suite. The test that created it is called
 *
 * testGetSurveyChainDelete and can be found in
-* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/SurveyTest.php
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/SurveyTest.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
+*/