Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
3 | * Test Generated example of using uf_group create API. | |
4 | * | |
50fb255d | 5 | * @return array |
6 | * API result array | |
7 | */ | |
8 | function uf_group_create_example() { | |
9 | $params = array( | |
10 | 'add_captcha' => 1, | |
11 | 'add_contact_to_group' => 1, | |
12 | 'group' => 1, | |
13 | 'cancel_URL' => 'http://example.org/cancel', | |
14 | 'created_date' => '2009-06-27 00:00:00', | |
15 | 'created_id' => 1, | |
16 | 'group_type' => 'Individual,Contact', | |
17 | 'help_post' => 'help post', | |
18 | 'help_pre' => 'help pre', | |
19 | 'is_active' => 0, | |
20 | 'is_cms_user' => 1, | |
21 | 'is_edit_link' => 1, | |
22 | 'is_map' => 1, | |
23 | 'is_reserved' => 1, | |
24 | 'is_uf_link' => 1, | |
25 | 'is_update_dupe' => 1, | |
26 | 'name' => 'Test_Group', | |
27 | 'notify' => 'admin@example.org', | |
28 | 'post_URL' => 'http://example.org/post', | |
29 | 'title' => 'Test Group', | |
30 | ); | |
6a488035 | 31 | |
50fb255d | 32 | try{ |
33 | $result = civicrm_api3('uf_group', 'create', $params); | |
34 | } | |
35 | catch (CiviCRM_API3_Exception $e) { | |
36 | // Handle error here. | |
37 | $errorMessage = $e->getMessage(); | |
38 | $errorCode = $e->getErrorCode(); | |
39 | $errorData = $e->getExtraParams(); | |
40 | return array( | |
41 | 'error' => $errorMessage, | |
42 | 'error_code' => $errorCode, | |
43 | 'error_data' => $errorData, | |
44 | ); | |
45 | } | |
46 | ||
47 | return $result; | |
6a488035 TO |
48 | } |
49 | ||
fb32de45 | 50 | /** |
50fb255d | 51 | * Function returns array of result expected from previous function. |
52 | * | |
53 | * @return array | |
54 | * API result array | |
6a488035 | 55 | */ |
50fb255d | 56 | function uf_group_create_expectedresult() { |
6a488035 | 57 | |
ee600d6f | 58 | $expectedResult = array( |
50fb255d | 59 | 'is_error' => 0, |
60 | 'version' => 3, | |
61 | 'count' => 1, | |
62 | 'id' => 2, | |
63 | 'values' => array( | |
f27f2724 | 64 | '2' => array( |
50fb255d | 65 | 'id' => '2', |
66 | 'is_active' => 0, | |
67 | 'group_type' => 'Individual,Contact', | |
68 | 'title' => 'Test Group', | |
69 | 'description' => '', | |
70 | 'help_pre' => 'help pre', | |
71 | 'help_post' => 'help post', | |
72 | 'limit_listings_group_id' => '1', | |
73 | 'post_URL' => 'http://example.org/post', | |
74 | 'add_to_group_id' => '1', | |
75 | 'add_captcha' => '1', | |
76 | 'is_map' => '1', | |
77 | 'is_edit_link' => '1', | |
78 | 'is_uf_link' => '1', | |
79 | 'is_update_dupe' => '1', | |
80 | 'cancel_URL' => 'http://example.org/cancel', | |
81 | 'is_cms_user' => '1', | |
82 | 'notify' => 'admin@example.org', | |
83 | 'is_reserved' => '1', | |
84 | 'name' => 'Test_Group_2', | |
85 | 'created_id' => '1', | |
86 | 'created_date' => '2013-07-28 08:49:19', | |
87 | 'is_proximity_search' => '', | |
88 | ), | |
6a488035 | 89 | ), |
50fb255d | 90 | ); |
6a488035 | 91 | |
fb32de45 | 92 | return $expectedResult; |
6a488035 TO |
93 | } |
94 | ||
50fb255d | 95 | /** |
96 | * This example has been generated from the API test suite. | |
97 | * The test that created it is called | |
98 | * testUFGroupCreate | |
99 | * and can be found in | |
69d79249 | 100 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/UFGroupTest.php |
6a488035 TO |
101 | * |
102 | * You can see the outcome of the API tests at | |
69d79249 | 103 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
104 | * |
105 | * To Learn about the API read | |
69d79249 | 106 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 107 | * |
69d79249 | 108 | * Browse the api on your own site with the api explorer |
41d4d31f | 109 | * http://MYSITE.ORG/path/to/civicrm/api |
6a488035 TO |
110 | * |
111 | * Read more about testing here | |
112 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
113 | * | |
114 | * API Standards documentation: | |
115 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 116 | */ |