commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / api / v3 / examples / ReportTemplate / Getrows.php
1 <?php
2 /**
3 * Test Generated example demonstrating the ReportTemplate.getrows API.
4 *
5 * Retrieve rows from a report template (optionally providing the instance_id).
6 *
7 * @return array
8 * API result array
9 */
10 function report_template_getrows_example() {
11 $params = array(
12 'report_id' => 'contact/summary',
13 'options' => array(
14 'metadata' => array(
15 '0' => 'labels',
16 '1' => 'title',
17 ),
18 ),
19 );
20
21 try{
22 $result = civicrm_api3('ReportTemplate', 'getrows', $params);
23 }
24 catch (CiviCRM_API3_Exception $e) {
25 // Handle error here.
26 $errorMessage = $e->getMessage();
27 $errorCode = $e->getErrorCode();
28 $errorData = $e->getExtraParams();
29 return array(
30 'error' => $errorMessage,
31 'error_code' => $errorCode,
32 'error_data' => $errorData,
33 );
34 }
35
36 return $result;
37 }
38
39 /**
40 * Function returns array of result expected from previous function.
41 *
42 * @return array
43 * API result array
44 */
45 function report_template_getrows_expectedresult() {
46
47 $expectedResult = array(
48 'is_error' => 0,
49 'version' => 3,
50 'count' => 2,
51 'values' => array(
52 '0' => array(
53 'civicrm_contact_sort_name' => 'Default Organization',
54 'civicrm_contact_id' => '1',
55 ),
56 '1' => array(
57 'civicrm_contact_sort_name' => 'Second Domain',
58 'civicrm_contact_id' => '2',
59 ),
60 ),
61 'metadata' => array(
62 'title' => 'ERROR: Title is not Set',
63 'labels' => array(
64 'civicrm_contact_sort_name' => 'Contact Name',
65 'civicrm_contact_id' => 'Internal Contact ID',
66 ),
67 ),
68 );
69
70 return $expectedResult;
71 }
72
73 /*
74 * This example has been generated from the API test suite.
75 * The test that created it is called "testReportTemplateGetRowsContactSummary"
76 * and can be found at:
77 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ReportTemplateTest.php
78 *
79 * You can see the outcome of the API tests at
80 * https://test.civicrm.org/job/CiviCRM-master-git/
81 *
82 * To Learn about the API read
83 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
84 *
85 * Browse the api on your own site with the api explorer
86 * http://MYSITE.ORG/path/to/civicrm/api
87 *
88 * Read more about testing here
89 * http://wiki.civicrm.org/confluence/display/CRM/Testing
90 *
91 * API Standards documentation:
92 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
93 */