CRM-13072 more test class upgrades
[civicrm-core.git] / api / v3 / examples / Contact / APIChainedArrayFormats.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 return formats are used. Note that no notes
5 *custom fields or memberships exist *
6a488035
TO
6 */
7function contact_get_example(){
edb0d67a 8$params = array(
6a488035 9 'id' => 1,
edb0d67a 10 'api.website.getValue' => array(
6a488035
TO
11 'return' => 'url',
12 ),
13 'api.Contribution.getCount' => array(),
14 'api.CustomValue.get' => 1,
15 'api.Note.get' => 1,
16 'api.Membership.getCount' => array(),
17);
18
fb32de45 19try{
20 $result = civicrm_api3('contact', 'get', $params);
21}
22catch (CiviCRM_API3_Exception $e) {
23 // handle error here
24 $errorMessage = $e->getMessage();
25 $errorCode = $e->getErrorCode();
26 $errorData = $e->getExtraParams();
27 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
28}
6a488035 29
fb32de45 30return $result;
6a488035
TO
31}
32
fb32de45 33/**
6a488035
TO
34 * Function returns array of result expected from previous function
35 */
36function contact_get_expectedresult(){
37
edb0d67a 38 $expectedResult = array(
6a488035
TO
39 'is_error' => 0,
40 'version' => 3,
41 'count' => 1,
42 'id' => 1,
edb0d67a 43 'values' => array(
44 '1' => array(
6a488035
TO
45 'contact_id' => '1',
46 'contact_type' => 'Individual',
47 'contact_sub_type' => '',
48 'sort_name' => 'xyz3, abc3',
49 'display_name' => 'abc3 xyz3',
50 'do_not_email' => 0,
51 'do_not_phone' => 0,
52 'do_not_mail' => 0,
53 'do_not_sms' => 0,
54 'do_not_trade' => 0,
55 'is_opt_out' => 0,
56 'legal_identifier' => '',
57 'external_identifier' => '',
58 'nick_name' => '',
59 'legal_name' => '',
60 'image_URL' => '',
61 'preferred_mail_format' => 'Both',
62 'first_name' => 'abc3',
63 'middle_name' => '',
64 'last_name' => 'xyz3',
65 'job_title' => '',
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' => '',
84 'state_province_name' => '',
85 'state_province' => '',
86 'country_id' => '',
87 'country' => '',
88 'phone_id' => '',
89 'phone_type_id' => '',
90 'phone' => '',
91 'email_id' => '1',
92 'email' => 'man3@yahoo.com',
93 'on_hold' => 0,
94 'im_id' => '',
95 'provider_id' => '',
96 'im' => '',
97 'worldregion_id' => '',
98 'world_region' => '',
99 'id' => '1',
100 'api.website.getValue' => 'http://civicrm.org',
101 'api.Contribution.getCount' => 2,
edb0d67a 102 'api.CustomValue.get' => array(
6a488035
TO
103 'is_error' => 0,
104 'version' => 3,
105 'count' => 0,
106 'values' => array(),
107 ),
edb0d67a 108 'api.Note.get' => array(
6a488035
TO
109 'is_error' => 0,
110 'version' => 3,
111 'count' => 0,
112 'values' => array(),
113 ),
114 'api.Membership.getCount' => 0,
115 ),
116 ),
117);
118
fb32de45 119 return $expectedResult;
6a488035
TO
120}
121
122
123/*
124* This example has been generated from the API test suite. The test that created it is called
125*
126* testGetIndividualWithChainedArraysFormats and can be found in
127* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
128*
129* You can see the outcome of the API tests at
130* http://tests.dev.civicrm.org/trunk/results-api_v3
131*
132* To Learn about the API read
133* http://book.civicrm.org/developer/current/techniques/api/
134*
135* and review the wiki at
136* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
137*
138* Read more about testing here
139* http://wiki.civicrm.org/confluence/display/CRM/Testing
140*
141* API Standards documentation:
142* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
143*/