Ian province abbreviation patch - issue 724
[civicrm-core.git] / api / v3 / examples / Address / AddressLike.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the Address.get API.
50fb255d 4 *
5c49fee0 5 * Demonstrates Use of Like.
50fb255d 6 *
7 * @return array
8 * API result array
9 */
10function address_get_example() {
11 $params = array(
12 'street_address' => array(
6a488035
TO
13 'LIKE' => '%mb%',
14 ),
50fb255d 15 'sequential' => 1,
16 );
6a488035 17
50fb255d 18 try{
a828d7b8 19 $result = civicrm_api3('Address', 'get', $params);
50fb255d 20 }
21 catch (CiviCRM_API3_Exception $e) {
22 // Handle error here.
23 $errorMessage = $e->getMessage();
24 $errorCode = $e->getErrorCode();
25 $errorData = $e->getExtraParams();
26 return array(
27 'error' => $errorMessage,
28 'error_code' => $errorCode,
29 'error_data' => $errorData,
30 );
31 }
6a488035 32
50fb255d 33 return $result;
6a488035
TO
34}
35
fb32de45 36/**
50fb255d 37 * Function returns array of result expected from previous function.
38 *
39 * @return array
40 * API result array
6a488035 41 */
50fb255d 42function address_get_expectedresult() {
6a488035 43
edb0d67a 44 $expectedResult = array(
50fb255d 45 'is_error' => 0,
46 'version' => 3,
47 'count' => 1,
48 'id' => 1,
49 'values' => array(
edb0d67a 50 '0' => array(
50fb255d 51 'id' => '1',
52 'contact_id' => '20',
53 'location_type_id' => '18',
54 'is_primary' => '1',
55 'is_billing' => 0,
56 'street_address' => 'Ambachtstraat 23',
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 ),
6a488035 64 ),
50fb255d 65 );
6a488035 66
fb32de45 67 return $expectedResult;
6a488035
TO
68}
69
a828d7b8 70/*
50fb255d 71* This example has been generated from the API test suite.
a828d7b8
CW
72* The test that created it is called "testGetAddressLikeSuccess"
73* and can be found at:
69d79249 74* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/AddressTest.php
6a488035
TO
75*
76* You can see the outcome of the API tests at
69d79249 77* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
78*
79* To Learn about the API read
69d79249 80* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 81*
69d79249 82* Browse the api on your own site with the api explorer
41d4d31f 83* http://MYSITE.ORG/path/to/civicrm/api
6a488035
TO
84*
85* Read more about testing here
86* http://wiki.civicrm.org/confluence/display/CRM/Testing
87*
88* API Standards documentation:
89* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 90*/