Ian province abbreviation patch - issue 724
[civicrm-core.git] / api / v3 / examples / LocBlock / Create.php
... / ...
CommitLineData
1<?php
2/**
3 * Test Generated example demonstrating the LocBlock.create API.
4 *
5 * Create locBlock with existing entities
6 *
7 * @return array
8 * API result array
9 */
10function loc_block_create_example() {
11 $params = array(
12 'address_id' => 2,
13 'phone_id' => 2,
14 'email_id' => 3,
15 );
16
17 try{
18 $result = civicrm_api3('LocBlock', 'create', $params);
19 }
20 catch (CiviCRM_API3_Exception $e) {
21 // Handle error here.
22 $errorMessage = $e->getMessage();
23 $errorCode = $e->getErrorCode();
24 $errorData = $e->getExtraParams();
25 return array(
26 'error' => $errorMessage,
27 'error_code' => $errorCode,
28 'error_data' => $errorData,
29 );
30 }
31
32 return $result;
33}
34
35/**
36 * Function returns array of result expected from previous function.
37 *
38 * @return array
39 * API result array
40 */
41function loc_block_create_expectedresult() {
42
43 $expectedResult = array(
44 'is_error' => 0,
45 'version' => 3,
46 'count' => 1,
47 'id' => 2,
48 'values' => array(
49 '2' => array(
50 'id' => '2',
51 'address_id' => '2',
52 'email_id' => '3',
53 'phone_id' => '2',
54 'im_id' => '',
55 'address_2_id' => '',
56 'email_2_id' => '',
57 'phone_2_id' => '',
58 'im_2_id' => '',
59 ),
60 ),
61 );
62
63 return $expectedResult;
64}
65
66/*
67* This example has been generated from the API test suite.
68* The test that created it is called "testCreateLocBlock"
69* and can be found at:
70* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/LocBlockTest.php
71*
72* You can see the outcome of the API tests at
73* https://test.civicrm.org/job/CiviCRM-master-git/
74*
75* To Learn about the API read
76* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
77*
78* Browse the api on your own site with the api explorer
79* http://MYSITE.ORG/path/to/civicrm/api
80*
81* Read more about testing here
82* http://wiki.civicrm.org/confluence/display/CRM/Testing
83*
84* API Standards documentation:
85* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
86*/