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