Commit | Line | Data |
---|---|---|
dc5a7701 E |
1 | <?php |
2 | /** | |
50fb255d | 3 | * @file |
4 | * Test Generated API Example. | |
5 | * See bottom of this file for more detail. | |
dc5a7701 | 6 | */ |
dc5a7701 | 7 | |
50fb255d | 8 | /** |
9 | * Test Generated example of using website getfields API. | |
10 | * | |
11 | * | |
12 | * @return array | |
13 | * API result array | |
14 | */ | |
15 | function website_getfields_example() { | |
16 | $params = array( | |
17 | 'action' => 'get', | |
18 | ); | |
19 | ||
20 | try{ | |
21 | $result = civicrm_api3('website', 'getfields', $params); | |
22 | } | |
23 | catch (CiviCRM_API3_Exception $e) { | |
24 | // Handle error here. | |
25 | $errorMessage = $e->getMessage(); | |
26 | $errorCode = $e->getErrorCode(); | |
27 | $errorData = $e->getExtraParams(); | |
28 | return array( | |
29 | 'error' => $errorMessage, | |
30 | 'error_code' => $errorCode, | |
31 | 'error_data' => $errorData, | |
32 | ); | |
33 | } | |
dc5a7701 | 34 | |
50fb255d | 35 | return $result; |
dc5a7701 E |
36 | } |
37 | ||
38 | /** | |
50fb255d | 39 | * Function returns array of result expected from previous function. |
40 | * | |
41 | * @return array | |
42 | * API result array | |
dc5a7701 | 43 | */ |
50fb255d | 44 | function website_getfields_expectedresult() { |
dc5a7701 E |
45 | |
46 | $expectedResult = array( | |
50fb255d | 47 | 'is_error' => 0, |
48 | 'version' => 3, | |
49 | 'count' => 4, | |
50 | 'values' => array( | |
dc5a7701 | 51 | 'id' => array( |
50fb255d | 52 | 'name' => 'id', |
53 | 'type' => 1, | |
54 | 'title' => 'Website ID', | |
55 | 'required' => TRUE, | |
56 | 'api.aliases' => array( | |
57 | '0' => 'website_id', | |
dc5a7701 | 58 | ), |
50fb255d | 59 | ), |
dc5a7701 | 60 | 'contact_id' => array( |
50fb255d | 61 | 'name' => 'contact_id', |
62 | 'type' => 1, | |
63 | 'title' => 'Contact', | |
64 | 'FKClassName' => 'CRM_Contact_DAO_Contact', | |
65 | 'FKApiName' => 'Contact', | |
66 | ), | |
dc5a7701 | 67 | 'url' => array( |
50fb255d | 68 | 'name' => 'url', |
69 | 'type' => 2, | |
70 | 'title' => 'Website', | |
71 | 'maxlength' => 128, | |
72 | 'size' => 30, | |
73 | 'import' => TRUE, | |
74 | 'where' => 'civicrm_website.url', | |
75 | 'headerPattern' => '/Website/i', | |
76 | 'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/', | |
77 | 'export' => TRUE, | |
78 | 'html' => array( | |
79 | 'type' => 'Text', | |
dc5a7701 | 80 | ), |
50fb255d | 81 | ), |
dc5a7701 | 82 | 'website_type_id' => array( |
50fb255d | 83 | 'name' => 'website_type_id', |
84 | 'type' => 1, | |
85 | 'title' => 'Website Type', | |
86 | 'html' => array( | |
87 | 'type' => 'Select', | |
88 | ), | |
89 | 'pseudoconstant' => array( | |
90 | 'optionGroupName' => 'website_type', | |
dc5a7701 | 91 | ), |
50fb255d | 92 | ), |
dc5a7701 | 93 | ), |
50fb255d | 94 | ); |
dc5a7701 E |
95 | |
96 | return $expectedResult; | |
97 | } | |
98 | ||
50fb255d | 99 | /** |
100 | * This example has been generated from the API test suite. | |
101 | * The test that created it is called | |
102 | * testGetFields | |
103 | * and can be found in | |
69d79249 | 104 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/WebsiteTest.php |
dc5a7701 E |
105 | * |
106 | * You can see the outcome of the API tests at | |
69d79249 | 107 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
dc5a7701 E |
108 | * |
109 | * To Learn about the API read | |
69d79249 | 110 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
dc5a7701 | 111 | * |
69d79249 E |
112 | * Browse the api on your own site with the api explorer |
113 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
dc5a7701 E |
114 | * |
115 | * Read more about testing here | |
116 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
117 | * | |
118 | * API Standards documentation: | |
119 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
120 | */ |