Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using address get API | |
4 | * Demonstrates Use of sort filter * | |
6a488035 TO |
5 | */ |
6 | function address_get_example(){ | |
edb0d67a | 7 | $params = array( |
8 | 'options' => array( | |
6a488035 TO |
9 | 'sort' => 'street_address DESC', |
10 | 'limit' => 2, | |
11 | ), | |
6a488035 TO |
12 | 'sequential' => 1, |
13 | ); | |
14 | ||
fb32de45 | 15 | try{ |
16 | $result = civicrm_api3('address', 'get', $params); | |
17 | } | |
18 | catch (CiviCRM_API3_Exception $e) { | |
19 | // handle error here | |
20 | $errorMessage = $e->getMessage(); | |
21 | $errorCode = $e->getErrorCode(); | |
22 | $errorData = $e->getExtraParams(); | |
23 | return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); | |
24 | } | |
6a488035 | 25 | |
fb32de45 | 26 | return $result; |
6a488035 TO |
27 | } |
28 | ||
fb32de45 | 29 | /** |
6a488035 TO |
30 | * Function returns array of result expected from previous function |
31 | */ | |
32 | function address_get_expectedresult(){ | |
33 | ||
edb0d67a | 34 | $expectedResult = array( |
6a488035 TO |
35 | 'is_error' => 0, |
36 | 'version' => 3, | |
37 | 'count' => 2, | |
edb0d67a | 38 | 'values' => array( |
39 | '0' => array( | |
6a488035 TO |
40 | 'id' => '9', |
41 | 'contact_id' => '11', | |
42 | 'location_type_id' => '14', | |
43 | 'is_primary' => '1', | |
44 | 'is_billing' => 0, | |
45 | 'street_address' => 'Ambachtstraat 23', | |
46 | 'street_number' => '23', | |
47 | 'street_name' => 'Ambachtstraat', | |
48 | 'city' => 'Brummen', | |
49 | 'postal_code' => '6971 BN', | |
50 | 'country_id' => '1152', | |
51 | 'manual_geo_code' => 0, | |
52 | ), | |
edb0d67a | 53 | '1' => array( |
6a488035 TO |
54 | 'id' => '1', |
55 | 'contact_id' => '2', | |
56 | 'location_type_id' => '1', | |
57 | 'is_primary' => '1', | |
58 | 'is_billing' => '1', | |
59 | 'street_address' => '15 Main St', | |
60 | 'street_number' => '15', | |
61 | 'street_number_suffix' => 'S', | |
62 | 'street_name' => 'Main', | |
63 | 'street_type' => 'St', | |
64 | 'city' => 'Collinsville', | |
65 | 'state_province_id' => '1006', | |
66 | 'postal_code' => '6022', | |
67 | 'country_id' => '1228', | |
68 | 'geo_code_1' => '41.8328', | |
69 | 'geo_code_2' => '-72.9253', | |
70 | 'manual_geo_code' => 0, | |
71 | ), | |
72 | ), | |
73 | ); | |
74 | ||
fb32de45 | 75 | return $expectedResult; |
6a488035 TO |
76 | } |
77 | ||
78 | ||
79 | /* | |
80 | * This example has been generated from the API test suite. The test that created it is called | |
81 | * | |
82 | * testGetAddressSort and can be found in | |
69d79249 | 83 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/AddressTest.php |
6a488035 TO |
84 | * |
85 | * You can see the outcome of the API tests at | |
69d79249 | 86 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
87 | * |
88 | * To Learn about the API read | |
69d79249 | 89 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 90 | * |
69d79249 E |
91 | * Browse the api on your own site with the api explorer |
92 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
6a488035 TO |
93 | * |
94 | * Read more about testing here | |
95 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
96 | * | |
97 | * API Standards documentation: | |
98 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 99 | */ |