Merge pull request #1556 from pratik-joshi/CRM-13276
[civicrm-core.git] / api / v3 / examples / Membership / filterIsCurrent.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using membership get API
4 * Demonstrates use of 'filter' active_only' param *
6a488035
TO
5 */
6function membership_get_example(){
53ca8fd7 7$params = array(
37eda84b 8 'contact_id' => 17,
53ca8fd7 9 'filters' => array(
6a488035
TO
10 'is_current' => 1,
11 ),
6a488035
TO
12);
13
fb32de45 14try{
15 $result = civicrm_api3('membership', 'get', $params);
16}
17catch (CiviCRM_API3_Exception $e) {
18 // handle error here
19 $errorMessage = $e->getMessage();
20 $errorCode = $e->getErrorCode();
21 $errorData = $e->getExtraParams();
22 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
23}
6a488035 24
fb32de45 25return $result;
6a488035
TO
26}
27
fb32de45 28/**
6a488035
TO
29 * Function returns array of result expected from previous function
30 */
31function membership_get_expectedresult(){
32
53ca8fd7 33 $expectedResult = array(
6a488035
TO
34 'is_error' => 0,
35 'version' => 3,
36 'count' => 1,
37 'id' => 1,
53ca8fd7 38 'values' => array(
39 '1' => array(
6a488035
TO
40 'id' => '1',
41 'membership_id' => '1',
37eda84b 42 'contact_id' => '17',
43 'membership_contact_id' => '17',
44 'membership_type_id' => '25',
6a488035 45 'join_date' => '2009-01-21',
9f1b81e0 46 'start_date' => '2013-07-29 00:00:00',
6a488035 47 'membership_start_date' => '2009-01-21',
9f1b81e0 48 'end_date' => '2013-08-04 00:00:00',
6a488035
TO
49 'membership_end_date' => '2009-12-21',
50 'source' => 'Payment',
51 'membership_source' => 'Payment',
37eda84b 52 'status_id' => '20',
6a488035
TO
53 'is_override' => '1',
54 'is_test' => 0,
55 'member_is_test' => 0,
56 'is_pay_later' => 0,
57 'member_is_pay_later' => 0,
58 'membership_name' => 'General',
59 'relationship_name' => 'Child of',
60 ),
61 ),
62);
63
fb32de45 64 return $expectedResult;
6a488035
TO
65}
66
67
68/*
69* This example has been generated from the API test suite. The test that created it is called
70*
71* testGetOnlyActive and can be found in
72* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/MembershipTest.php
73*
74* You can see the outcome of the API tests at
75* http://tests.dev.civicrm.org/trunk/results-api_v3
76*
77* To Learn about the API read
78* http://book.civicrm.org/developer/current/techniques/api/
79*
80* and review the wiki at
81* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
82*
83* Read more about testing here
84* http://wiki.civicrm.org/confluence/display/CRM/Testing
85*
86* API Standards documentation:
87* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
88*/