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