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