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