CRM-13234 one line fix for test failure caused by change to set-up class
[civicrm-core.git] / api / v3 / examples / Contact / APIChainedArrayMultipleCustom.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using contact get API
4 * /*this demonstrates the usage of chained api functions. A variety of techniques are used *
6a488035
TO
5 */
6function contact_get_example(){
edb0d67a 7$params = array(
6a488035 8 'id' => 1,
edb0d67a 9 'api.website.getValue' => array(
6a488035
TO
10 'return' => 'url',
11 ),
12 'api.Contribution.getCount' => array(),
13 'api.CustomValue.get' => 1,
14);
15
fb32de45 16try{
17 $result = civicrm_api3('contact', 'get', $params);
18}
19catch (CiviCRM_API3_Exception $e) {
20 // handle error here
21 $errorMessage = $e->getMessage();
22 $errorCode = $e->getErrorCode();
23 $errorData = $e->getExtraParams();
24 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
25}
6a488035 26
fb32de45 27return $result;
6a488035
TO
28}
29
fb32de45 30/**
6a488035
TO
31 * Function returns array of result expected from previous function
32 */
33function contact_get_expectedresult(){
34
edb0d67a 35 $expectedResult = array(
6a488035
TO
36 'is_error' => 0,
37 'version' => 3,
38 'count' => 1,
39 'id' => 1,
edb0d67a 40 'values' => array(
41 '1' => array(
6a488035
TO
42 'contact_id' => '1',
43 'contact_type' => 'Individual',
44 'contact_sub_type' => '',
45 'sort_name' => 'xyz3, abc3',
46 'display_name' => 'abc3 xyz3',
47 'do_not_email' => 0,
48 'do_not_phone' => 0,
49 'do_not_mail' => 0,
50 'do_not_sms' => 0,
51 'do_not_trade' => 0,
52 'is_opt_out' => 0,
53 'legal_identifier' => '',
54 'external_identifier' => '',
55 'nick_name' => '',
56 'legal_name' => '',
57 'image_URL' => '',
58 'preferred_mail_format' => 'Both',
59 'first_name' => 'abc3',
60 'middle_name' => '',
61 'last_name' => 'xyz3',
6ecbca5b 62 'prefix_id' => '',
63 'suffix_id' => '',
6a488035 64 'job_title' => '',
6ecbca5b 65 'gender_id' => '',
6a488035
TO
66 'birth_date' => '',
67 'is_deceased' => 0,
68 'deceased_date' => '',
69 'household_name' => '',
70 'organization_name' => '',
71 'sic_code' => '',
72 'contact_is_deleted' => 0,
6a488035
TO
73 'current_employer' => '',
74 'address_id' => '',
75 'street_address' => '',
76 'supplemental_address_1' => '',
77 'supplemental_address_2' => '',
78 'city' => '',
79 'postal_code_suffix' => '',
80 'postal_code' => '',
81 'geo_code_1' => '',
82 'geo_code_2' => '',
83 'state_province_id' => '',
6a488035 84 'country_id' => '',
6a488035
TO
85 'phone_id' => '',
86 'phone_type_id' => '',
87 'phone' => '',
88 'email_id' => '1',
89 'email' => 'man3@yahoo.com',
90 'on_hold' => 0,
91 'im_id' => '',
92 'provider_id' => '',
93 'im' => '',
94 'worldregion_id' => '',
95 'world_region' => '',
6ecbca5b 96 'individual_prefix' => '',
97 'individual_suffix' => '',
98 'gender' => '',
9f1b81e0 99 'state_province_name' => '',
100 'state_province' => '',
101 'country' => '',
6a488035
TO
102 'id' => '1',
103 'api.website.getValue' => 'http://civicrm.org',
104 'api.Contribution.getCount' => 2,
edb0d67a 105 'api.CustomValue.get' => array(
6a488035
TO
106 'is_error' => 0,
107 'version' => 3,
fb32de45 108 'count' => 8,
edb0d67a 109 'values' => array(
110 '0' => array(
6a488035
TO
111 'entity_id' => '1',
112 'latest' => 'value 4',
fb32de45 113 'id' => '1',
114 'entity_table' => 'Contact',
6a488035 115 ),
edb0d67a 116 '1' => array(
6a488035
TO
117 'entity_table' => 'Contact',
118 ),
edb0d67a 119 '2' => array(
6a488035
TO
120 'entity_id' => '1',
121 'latest' => 'value 3',
fb32de45 122 'id' => '2',
6a488035 123 '1' => 'value 2',
fb32de45 124 'entity_table' => 'Contact',
6a488035
TO
125 '2' => 'value 3',
126 ),
edb0d67a 127 '3' => array(
6a488035 128 'entity_id' => '1',
b422b715 129 'latest' => 'defaultValue',
fb32de45 130 'id' => '3',
6a488035 131 '1' => 'warm beer',
b422b715 132 '2' => 'defaultValue',
6a488035 133 ),
fb32de45 134 '4' => array(
6a488035 135 'entity_id' => '1',
b422b715 136 'latest' => 'defaultValue',
fb32de45 137 'id' => '4',
b422b715 138 '1' => 'defaultValue',
139 '2' => 'defaultValue',
6a488035 140 ),
fb32de45 141 '5' => array(
6a488035 142 'entity_id' => '1',
b422b715 143 'latest' => 'defaultValue',
fb32de45 144 'id' => '5',
b422b715 145 '1' => 'defaultValue',
6a488035 146 ),
fb32de45 147 '6' => array(
6a488035
TO
148 'entity_id' => '1',
149 'latest' => 'vegemite',
fb32de45 150 'id' => '6',
6a488035
TO
151 '1' => 'vegemite',
152 ),
fb32de45 153 '7' => array(
6a488035 154 'entity_id' => '1',
b422b715 155 'latest' => 'defaultValue',
fb32de45 156 'id' => '7',
b422b715 157 '1' => 'defaultValue',
6a488035
TO
158 ),
159 ),
160 ),
161 ),
162 ),
163);
164
fb32de45 165 return $expectedResult;
6a488035
TO
166}
167
168
169/*
170* This example has been generated from the API test suite. The test that created it is called
171*
172* testGetIndividualWithChainedArraysAndMultipleCustom and can be found in
173* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
174*
175* You can see the outcome of the API tests at
176* http://tests.dev.civicrm.org/trunk/results-api_v3
177*
178* To Learn about the API read
179* http://book.civicrm.org/developer/current/techniques/api/
180*
181* and review the wiki at
182* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
183*
184* Read more about testing here
185* http://wiki.civicrm.org/confluence/display/CRM/Testing
186*
187* API Standards documentation:
188* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
189*/