commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / api / v3 / examples / Membership / FilterIsCurrent.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Membership.get API.
4 *
5 * Demonstrates use of 'filter' active_only' param.
6 *
7 * @return array
8 * API result array
9 */
10 function membership_get_example() {
11 $params = array(
12 'contact_id' => 44,
13 'filters' => array(
14 'is_current' => 1,
15 ),
16 );
17
18 try{
19 $result = civicrm_api3('Membership', 'get', $params);
20 }
21 catch (CiviCRM_API3_Exception $e) {
22 // Handle error here.
23 $errorMessage = $e->getMessage();
24 $errorCode = $e->getErrorCode();
25 $errorData = $e->getExtraParams();
26 return array(
27 'error' => $errorMessage,
28 'error_code' => $errorCode,
29 'error_data' => $errorData,
30 );
31 }
32
33 return $result;
34 }
35
36 /**
37 * Function returns array of result expected from previous function.
38 *
39 * @return array
40 * API result array
41 */
42 function membership_get_expectedresult() {
43
44 $expectedResult = array(
45 'is_error' => 0,
46 'version' => 3,
47 'count' => 1,
48 'id' => 1,
49 'values' => array(
50 '1' => array(
51 'id' => '1',
52 'contact_id' => '44',
53 'membership_type_id' => '27',
54 'join_date' => '2009-01-21',
55 'start_date' => '2013-07-29 00:00:00',
56 'end_date' => '2013-08-04 00:00:00',
57 'source' => 'Payment',
58 'status_id' => '21',
59 'is_override' => '1',
60 'is_test' => 0,
61 'is_pay_later' => 0,
62 'membership_name' => 'General',
63 'relationship_name' => 'Child of',
64 ),
65 ),
66 );
67
68 return $expectedResult;
69 }
70
71 /*
72 * This example has been generated from the API test suite.
73 * The test that created it is called "testGetOnlyActive"
74 * and can be found at:
75 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MembershipTest.php
76 *
77 * You can see the outcome of the API tests at
78 * https://test.civicrm.org/job/CiviCRM-master-git/
79 *
80 * To Learn about the API read
81 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
82 *
83 * Browse the api on your own site with the api explorer
84 * http://MYSITE.ORG/path/to/civicrm/api
85 *
86 * Read more about testing here
87 * http://wiki.civicrm.org/confluence/display/CRM/Testing
88 *
89 * API Standards documentation:
90 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
91 */