Merge remote-tracking branch 'upstream/4.3' into 4.3-master-2013-05-24-02-32-04
[civicrm-core.git] / api / v3 / examples / LocBlockCreateEntities.php
CommitLineData
6a488035
TO
1<?php
2
3/*
4 Create entities and location block in 1 api call
5 */
6function loc_block_createentities_example(){
7$params = array(
8 'version' => 3,
9 'email' => array(
10 'location_type_id' => 1,
11 'email' => 'test2@loc.block',
12 ),
13 'phone' => array(
14 'location_type_id' => 1,
15 'phone' => '987654321',
16 ),
17 'phone_2' => array(
18 'location_type_id' => 1,
19 'phone' => '456-7890',
20 ),
21 'address' => array(
22 'location_type_id' => 1,
23 'street_address' => '987654321',
24 ),
25);
26
27 $result = civicrm_api( 'loc_block','createEntities',$params );
28
29 return $result;
30}
31
32/*
33 * Function returns array of result expected from previous function
34 */
35function loc_block_createentities_expectedresult(){
36
37 $expectedResult = array(
38 'is_error' => 0,
39 'version' => 3,
40 'count' => 1,
41 'id' => 3,
42 'values' => array(
43 '3' => array(
44 'address' => array(
45 'id' => '3',
46 'location_type_id' => '1',
47 'is_primary' => 0,
48 'is_billing' => 0,
49 'street_address' => '987654321',
50 'manual_geo_code' => 0,
51 ),
52 'email' => array(
53 'id' => '4',
54 'contact_id' => 'null',
55 'location_type_id' => '1',
56 'email' => 'test2@loc.block',
57 'is_primary' => 0,
58 'is_billing' => '',
59 'on_hold' => '',
60 'is_bulkmail' => '',
61 'hold_date' => '',
62 'reset_date' => '',
63 'signature_text' => '',
64 'signature_html' => '',
65 ),
66 'phone' => array(
67 'id' => '3',
68 'contact_id' => 'null',
69 'location_type_id' => '1',
70 'is_primary' => 0,
71 'is_billing' => '',
72 'mobile_provider_id' => '',
73 'phone' => '987654321',
74 'phone_ext' => '',
75 'phone_numeric' => '',
76 'phone_type_id' => '',
77 ),
78 'phone_2' => array(
79 'id' => '4',
80 'contact_id' => 'null',
81 'location_type_id' => '1',
82 'is_primary' => 0,
83 'is_billing' => '',
84 'mobile_provider_id' => '',
85 'phone' => '456-7890',
86 'phone_ext' => '',
87 'phone_numeric' => '',
88 'phone_type_id' => '',
89 ),
90 'id' => '3',
91 'address_id' => '3',
92 'email_id' => '4',
93 'phone_id' => '3',
94 'im_id' => '',
95 'address_2_id' => '',
96 'email_2_id' => '',
97 'phone_2_id' => '4',
98 'im_2_id' => '',
99 ),
100 ),
101);
102
103 return $expectedResult ;
104}
105
106
107/*
108* This example has been generated from the API test suite. The test that created it is called
109*
110* testCreateLocBlockEntities and can be found in
111* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/LocBlockTest.php
112*
113* You can see the outcome of the API tests at
114* http://tests.dev.civicrm.org/trunk/results-api_v3
115*
116* To Learn about the API read
117* http://book.civicrm.org/developer/current/techniques/api/
118*
119* and review the wiki at
120* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
121*
122* Read more about testing here
123* http://wiki.civicrm.org/confluence/display/CRM/Testing
124*
125* API Standards documentation:
126* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
127*/