Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-03-02-21-30-06
[civicrm-core.git] / api / v3 / examples / EntityTag / Get.php
CommitLineData
fb32de45 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the EntityTag.get API.
50fb255d 4 *
50fb255d 5 * @return array
6 * API result array
7 */
8function entity_tag_get_example() {
9 $params = array(
a828d7b8 10 'contact_id' => 3,
50fb255d 11 );
fb32de45 12
50fb255d 13 try{
a828d7b8 14 $result = civicrm_api3('EntityTag', 'get', $params);
50fb255d 15 }
16 catch (CiviCRM_API3_Exception $e) {
17 // Handle error here.
18 $errorMessage = $e->getMessage();
19 $errorCode = $e->getErrorCode();
20 $errorData = $e->getExtraParams();
21 return array(
22 'error' => $errorMessage,
23 'error_code' => $errorCode,
24 'error_data' => $errorData,
25 );
26 }
27
28 return $result;
fb32de45 29}
30
31/**
50fb255d 32 * Function returns array of result expected from previous function.
33 *
34 * @return array
35 * API result array
fb32de45 36 */
50fb255d 37function entity_tag_get_expectedresult() {
fb32de45 38
39 $expectedResult = array(
50fb255d 40 'is_error' => 0,
a828d7b8
CW
41 'version' => 3,
42 'count' => 1,
43 'id' => 6,
44 'values' => array(
45 '6' => array(
46 'tag_id' => '6',
47 ),
48 ),
50fb255d 49 );
fb32de45 50
51 return $expectedResult;
52}
53
a828d7b8 54/*
50fb255d 55* This example has been generated from the API test suite.
a828d7b8
CW
56* The test that created it is called "testIndividualEntityTagGet"
57* and can be found at:
69d79249 58* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EntityTagTest.php
fb32de45 59*
60* You can see the outcome of the API tests at
69d79249 61* https://test.civicrm.org/job/CiviCRM-master-git/
fb32de45 62*
63* To Learn about the API read
69d79249 64* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
fb32de45 65*
69d79249 66* Browse the api on your own site with the api explorer
41d4d31f 67* http://MYSITE.ORG/path/to/civicrm/api
fb32de45 68*
69* Read more about testing here
70* http://wiki.civicrm.org/confluence/display/CRM/Testing
71*
72* API Standards documentation:
73* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 74*/