fix failing test, check contribution creating with default date of now
[civicrm-core.git] / api / v3 / examples / Contact / GroupFilterUsingContactAPI.php
1 <?php
2 /**
3 * Test Generated example of using contact get API
4 * Get all from group and display contacts *
5 */
6 function contact_get_example(){
7 $params = array(
8 'filter.group_id' => array(
9 '0' => 1,
10 '1' => 26,
11 ),
12 'contact_type' => 'Individual',
13 );
14
15 try{
16 $result = civicrm_api3('contact', 'get', $params);
17 }
18 catch (CiviCRM_API3_Exception $e) {
19 // handle error here
20 $errorMessage = $e->getMessage();
21 $errorCode = $e->getErrorCode();
22 $errorData = $e->getExtraParams();
23 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
24 }
25
26 return $result;
27 }
28
29 /**
30 * Function returns array of result expected from previous function
31 */
32 function contact_get_expectedresult(){
33
34 $expectedResult = array(
35 'is_error' => 0,
36 'version' => 3,
37 'count' => 1,
38 'id' => 1,
39 'values' => array(
40 '1' => array(
41 'contact_id' => '1',
42 'contact_type' => 'Individual',
43 'contact_sub_type' => '',
44 'sort_name' => 'man2@yahoo.com',
45 'display_name' => 'man2@yahoo.com',
46 'do_not_email' => 0,
47 'do_not_phone' => 0,
48 'do_not_mail' => 0,
49 'do_not_sms' => 0,
50 'do_not_trade' => 0,
51 'is_opt_out' => 0,
52 'legal_identifier' => '',
53 'external_identifier' => '',
54 'nick_name' => '',
55 'legal_name' => '',
56 'image_URL' => '',
57 'preferred_mail_format' => 'Both',
58 'first_name' => '',
59 'middle_name' => '',
60 'last_name' => '',
61 'prefix_id' => '',
62 'suffix_id' => '',
63 'job_title' => '',
64 'gender_id' => '',
65 'birth_date' => '',
66 'is_deceased' => 0,
67 'deceased_date' => '',
68 'household_name' => '',
69 'organization_name' => '',
70 'sic_code' => '',
71 'contact_is_deleted' => 0,
72 'current_employer' => '',
73 'address_id' => '',
74 'street_address' => '',
75 'supplemental_address_1' => '',
76 'supplemental_address_2' => '',
77 'city' => '',
78 'postal_code_suffix' => '',
79 'postal_code' => '',
80 'geo_code_1' => '',
81 'geo_code_2' => '',
82 'state_province_id' => '',
83 'country_id' => '',
84 'phone_id' => '',
85 'phone_type_id' => '',
86 'phone' => '',
87 'email_id' => '1',
88 'email' => 'man2@yahoo.com',
89 'on_hold' => 0,
90 'im_id' => '',
91 'provider_id' => '',
92 'im' => '',
93 'worldregion_id' => '',
94 'world_region' => '',
95 'individual_prefix' => '',
96 'individual_suffix' => '',
97 'gender' => '',
98 'state_province_name' => '',
99 'state_province' => '',
100 'country' => '',
101 'id' => '1',
102 ),
103 ),
104 );
105
106 return $expectedResult;
107 }
108
109
110 /*
111 * This example has been generated from the API test suite. The test that created it is called
112 *
113 * testGetGroupIDFromContact and can be found in
114 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
115 *
116 * You can see the outcome of the API tests at
117 * http://tests.dev.civicrm.org/trunk/results-api_v3
118 *
119 * To Learn about the API read
120 * http://book.civicrm.org/developer/current/techniques/api/
121 *
122 * and review the wiki at
123 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
124 *
125 * Read more about testing here
126 * http://wiki.civicrm.org/confluence/display/CRM/Testing
127 *
128 * API Standards documentation:
129 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
130 */