Update Test generated examples
[civicrm-core.git] / api / v3 / examples / Profile / Apply.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Profile.apply API.
4 *
5 * @return array
6 * API result array
7 */
8 function profile_apply_example() {
9 $params = array(
10 'profile_id' => 31,
11 'contact_id' => 3,
12 'first_name' => 'abc2',
13 'last_name' => 'xyz2',
14 'email-Primary' => 'abc2.xyz2@gmail.com',
15 'phone-1-1' => '022 321 826',
16 'country-1' => '1013',
17 'state_province-1' => '1000',
18 );
19
20 try{
21 $result = civicrm_api3('Profile', 'apply', $params);
22 }
23 catch (CiviCRM_API3_Exception $e) {
24 // Handle error here.
25 $errorMessage = $e->getMessage();
26 $errorCode = $e->getErrorCode();
27 $errorData = $e->getExtraParams();
28 return array(
29 'is_error' => 1,
30 'error_message' => $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 profile_apply_expectedresult() {
46
47 $expectedResult = array(
48 'is_error' => 0,
49 'version' => 3,
50 'count' => 11,
51 'values' => array(
52 'contact_type' => 'Individual',
53 'contact_sub_type' => '',
54 'contact_id' => 3,
55 'version' => 3,
56 'debug' => 1,
57 'profile_id' => 31,
58 'first_name' => 'abc2',
59 'last_name' => 'xyz2',
60 'email' => array(
61 '1' => array(
62 'location_type_id' => '1',
63 'is_primary' => 1,
64 'email' => 'abc2.xyz2@gmail.com',
65 ),
66 ),
67 'phone' => array(
68 '2' => array(
69 'location_type_id' => '1',
70 'is_primary' => 1,
71 'phone_type_id' => '1',
72 'phone' => '022 321 826',
73 ),
74 ),
75 'address' => array(
76 '1' => array(
77 'location_type_id' => '1',
78 'is_primary' => 1,
79 'country_id' => '1013',
80 'state_province_id' => '1000',
81 ),
82 ),
83 ),
84 );
85
86 return $expectedResult;
87 }
88
89 /*
90 * This example has been generated from the API test suite.
91 * The test that created it is called "testProfileApply"
92 * and can be found at:
93 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ProfileTest.php
94 *
95 * You can see the outcome of the API tests at
96 * https://test.civicrm.org/job/CiviCRM-master-git/
97 *
98 * To Learn about the API read
99 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
100 *
101 * Browse the api on your own site with the api explorer
102 * http://MYSITE.ORG/path/to/civicrm/api
103 *
104 * Read more about testing here
105 * http://wiki.civicrm.org/confluence/display/CRM/Testing
106 *
107 * API Standards documentation:
108 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
109 */