commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / api / v3 / examples / Country / Create.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Country.create API.
4 *
5 * @return array
6 * API result array
7 */
8 function country_create_example() {
9 $params = array(
10 'name' => 'Made Up Land',
11 'iso_code' => 'ZZ',
12 'region_id' => 1,
13 );
14
15 try{
16 $result = civicrm_api3('Country', 'create', $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(
24 'error' => $errorMessage,
25 'error_code' => $errorCode,
26 'error_data' => $errorData,
27 );
28 }
29
30 return $result;
31 }
32
33 /**
34 * Function returns array of result expected from previous function.
35 *
36 * @return array
37 * API result array
38 */
39 function country_create_expectedresult() {
40
41 $expectedResult = array(
42 'is_error' => 0,
43 'version' => 3,
44 'count' => 1,
45 'id' => 1252,
46 'values' => array(
47 '1252' => array(
48 'id' => '1252',
49 'name' => 'Made Up Land',
50 'iso_code' => 'ZZ',
51 'country_code' => '',
52 'address_format_id' => '',
53 'idd_prefix' => '',
54 'ndd_prefix' => '',
55 'region_id' => '1',
56 'is_province_abbreviated' => '',
57 ),
58 ),
59 );
60
61 return $expectedResult;
62 }
63
64 /*
65 * This example has been generated from the API test suite.
66 * The test that created it is called "testCreateCountry"
67 * and can be found at:
68 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CountryTest.php
69 *
70 * You can see the outcome of the API tests at
71 * https://test.civicrm.org/job/CiviCRM-master-git/
72 *
73 * To Learn about the API read
74 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
75 *
76 * Browse the api on your own site with the api explorer
77 * http://MYSITE.ORG/path/to/civicrm/api
78 *
79 * Read more about testing here
80 * http://wiki.civicrm.org/confluence/display/CRM/Testing
81 *
82 * API Standards documentation:
83 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
84 */