ade13f1fbe2cad305c994de0139787cd521303c5
[civicrm-core.git] / api / v3 / examples / UFGroup / Create.php
1 <?php
2 /**
3 * Test Generated example demonstrating the UFGroup.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('UFGroup', '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 'is_error' => 1,
42 'error_message' => $errorMessage,
43 'error_code' => $errorCode,
44 'error_data' => $errorData,
45 );
46 }
47
48 return $result;
49 }
50
51 /**
52 * Function returns array of result expected from previous function.
53 *
54 * @return array
55 * API result array
56 */
57 function uf_group_create_expectedresult() {
58
59 $expectedResult = array(
60 'is_error' => 0,
61 'version' => 3,
62 'count' => 1,
63 'id' => 2,
64 'values' => array(
65 '2' => array(
66 'id' => '2',
67 'is_active' => 0,
68 'group_type' => 'Individual,Contact',
69 'title' => 'Test Group',
70 'description' => '',
71 'help_pre' => 'help pre',
72 'help_post' => 'help post',
73 'limit_listings_group_id' => '1',
74 'post_URL' => 'http://example.org/post',
75 'add_to_group_id' => '1',
76 'add_captcha' => '1',
77 'is_map' => '1',
78 'is_edit_link' => '1',
79 'is_uf_link' => '1',
80 'is_update_dupe' => '1',
81 'cancel_URL' => 'http://example.org/cancel',
82 'is_cms_user' => '1',
83 'notify' => 'admin@example.org',
84 'is_reserved' => '1',
85 'name' => 'Test_Group',
86 'created_id' => '1',
87 'created_date' => '2013-07-28 08:49:19',
88 'is_proximity_search' => '',
89 ),
90 ),
91 );
92
93 return $expectedResult;
94 }
95
96 /*
97 * This example has been generated from the API test suite.
98 * The test that created it is called "testUFGroupCreate"
99 * and can be found at:
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 */