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