<?php
/**
- * Test Generated example of using report_template getrows API
- * Retrieve rows from a report template (optionally providing the instance_id) *
+ * Test Generated example demonstrating the ReportTemplate.getrows API.
+ *
+ * Retrieve rows from a report template (optionally providing the instance_id).
+ *
+ * @return array
+ * API result array
*/
-function report_template_getrows_example(){
-$params = array(
- 'report_id' => 'contact/summary',
- 'options' => array(
+function report_template_getrows_example() {
+ $params = array(
+ 'report_id' => 'contact/summary',
+ 'options' => array(
'metadata' => array(
- '0' => 'labels',
- '1' => 'title',
- ),
+ '0' => 'labels',
+ '1' => 'title',
+ ),
),
-);
+ );
-try{
- $result = civicrm_api3('report_template', 'getrows', $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);
-}
+ try{
+ $result = civicrm_api3('ReportTemplate', 'getrows', $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 returns array of result expected from previous function.
+ *
+ * @return array
+ * API result array
*/
-function report_template_getrows_expectedresult(){
+function report_template_getrows_expectedresult() {
$expectedResult = array(
- 'is_error' => 0,
- 'version' => 3,
- 'count' => 2,
- 'values' => array(
+ 'is_error' => 0,
+ 'version' => 3,
+ 'count' => 2,
+ 'values' => array(
'0' => array(
- 'civicrm_contact_sort_name' => 'Default Organization',
- 'civicrm_contact_id' => '1',
- 'civicrm_address_street_address' => '',
- 'civicrm_address_city' => '',
- 'civicrm_country_name' => '',
- ),
+ 'civicrm_contact_sort_name' => 'Default Organization',
+ 'civicrm_contact_id' => '1',
+ ),
'1' => array(
- 'civicrm_contact_sort_name' => 'Second Domain',
- 'civicrm_contact_id' => '2',
- 'civicrm_address_street_address' => '15 Main St',
- 'civicrm_address_city' => 'Collinsville',
- 'civicrm_country_name' => 'United States',
- ),
+ 'civicrm_contact_sort_name' => 'Second Domain',
+ 'civicrm_contact_id' => '2',
+ ),
),
- 'metadata' => array(
+ 'metadata' => array(
'title' => 'ERROR: Title is not Set',
'labels' => array(
- 'civicrm_contact_sort_name' => 'Contact Name',
- 'civicrm_contact_id' => 'Internal Contact ID',
- 'civicrm_address_street_address' => 'Street Address',
- 'civicrm_address_city' => 'City',
- 'civicrm_country_name' => 'Country',
- ),
+ 'civicrm_contact_sort_name' => 'Contact Name',
+ 'civicrm_contact_id' => 'Internal Contact ID',
+ ),
),
-);
+ );
return $expectedResult;
}
-
/*
-* This example has been generated from the API test suite. The test that created it is called
-*
-* testReportTemplateGetRowsContactSummary and can be found in
+* This example has been generated from the API test suite.
+* The test that created it is called "testReportTemplateGetRowsContactSummary"
+* and can be found at:
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ReportTemplateTest.php
*
* You can see the outcome of the API tests at
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
*
* Browse the api on your own site with the api explorer
-* http://MYSITE.ORG/path/to/civicrm/api/explorer
+* http://MYSITE.ORG/path/to/civicrm/api
*
* Read more about testing here
* http://wiki.civicrm.org/confluence/display/CRM/Testing