Merge pull request #5187 from mallezie/CRM-15982
[civicrm-core.git] / api / v3 / examples / UFGroup / Create.php
1 <?php
2 /**
3 * Test Generated example of using uf_group create API.
4 *
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 );
31
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;
48 }
49
50 /**
51 * Function returns array of result expected from previous function.
52 *
53 * @return array
54 * API result array
55 */
56 function uf_group_create_expectedresult() {
57
58 $expectedResult = array(
59 'is_error' => 0,
60 'version' => 3,
61 'count' => 1,
62 'id' => 2,
63 'values' => array(
64 '2' => array(
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 ),
89 ),
90 );
91
92 return $expectedResult;
93 }
94
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
100 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/UFGroupTest.php
101 *
102 * You can see the outcome of the API tests at
103 * https://test.civicrm.org/job/CiviCRM-master-git/
104 *
105 * To Learn about the API read
106 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
107 *
108 * Browse the api on your own site with the api explorer
109 * http://MYSITE.ORG/path/to/civicrm/api
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
116 */