Ian province abbreviation patch - issue 724
[civicrm-core.git] / api / v3 / examples / Relationship / filterIsCurrent.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the Relationship.get API.
50fb255d 4 *
5c49fee0 5 * Demonstrates is_current filter.
50fb255d 6 *
7 * @return array
8 * API result array
9 */
10function relationship_get_example() {
11 $params = array(
12 'filters' => array(
6a488035
TO
13 'is_current' => 1,
14 ),
50fb255d 15 );
6a488035 16
50fb255d 17 try{
a828d7b8 18 $result = civicrm_api3('Relationship', 'get', $params);
50fb255d 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 }
6a488035 31
50fb255d 32 return $result;
6a488035
TO
33}
34
fb32de45 35/**
50fb255d 36 * Function returns array of result expected from previous function.
37 *
38 * @return array
39 * API result array
6a488035 40 */
50fb255d 41function relationship_get_expectedresult() {
6a488035 42
26dcc9eb 43 $expectedResult = array(
50fb255d 44 'is_error' => 0,
45 'version' => 3,
46 'count' => 1,
47 'id' => 2,
48 'values' => array(
26dcc9eb 49 '2' => array(
50fb255d 50 'id' => '2',
51 'contact_id_a' => '83',
52 'contact_id_b' => '85',
53 'relationship_type_id' => '31',
54 'start_date' => '2013-07-29 00:00:00',
55 'is_active' => '1',
56 'description' => '',
57 'is_permission_a_b' => 0,
58 'is_permission_b_a' => 0,
59 ),
6a488035 60 ),
50fb255d 61 );
6a488035 62
fb32de45 63 return $expectedResult;
6a488035
TO
64}
65
a828d7b8 66/*
50fb255d 67* This example has been generated from the API test suite.
a828d7b8
CW
68* The test that created it is called "testGetIsCurrent"
69* and can be found at:
69d79249 70* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/RelationshipTest.php
6a488035
TO
71*
72* You can see the outcome of the API tests at
69d79249 73* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
74*
75* To Learn about the API read
69d79249 76* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 77*
69d79249 78* Browse the api on your own site with the api explorer
41d4d31f 79* http://MYSITE.ORG/path/to/civicrm/api
6a488035
TO
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
49f8272d 86*/