test tweaks and updated examples
[civicrm-core.git] / api / v3 / examples / UFGroupCreate.php
1 <?php
2 /**
3 * Test Generated example of using uf_group create API
4 * *
5 */
6 function uf_group_create_example(){
7 $params = array(
8 'add_captcha' => 1,
9 'add_contact_to_group' => 1,
10 'group' => 1,
11 'cancel_URL' => 'http://example.org/cancel',
12 'created_date' => '2009-06-27 00:00:00',
13 'created_id' => 1,
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',
28 );
29
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 }
40
41 return $result;
42 }
43
44 /**
45 * Function returns array of result expected from previous function
46 */
47 function uf_group_create_expectedresult(){
48
49 $expectedResult = array(
50 'is_error' => 0,
51 'version' => 3,
52 'count' => 1,
53 'id' => 2,
54 'values' => array(
55 '2' => array(
56 'id' => '2',
57 'is_active' => 0,
58 'group_type' => 'Individual,Contact',
59 'title' => 'Test Group',
60 'description' => '',
61 'help_pre' => 'help pre',
62 'help_post' => 'help post',
63 'limit_listings_group_id' => '1',
64 'post_URL' => 'http://example.org/post',
65 'add_to_group_id' => '1',
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',
75 'name' => 'Test_Group_2',
76 'created_id' => '1',
77 'created_date' => '2013-07-28 08:49:19',
78 'is_proximity_search' => '',
79 ),
80 ),
81 );
82
83 return $expectedResult;
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
107 */