fix failing test, check contribution creating with default date of now
[civicrm-core.git] / api / v3 / examples / MembershipUpdate.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using membership update API
4 * *
6a488035
TO
5 */
6function membership_update_example(){
53ca8fd7 7$params = array(
37eda84b 8 'contact_id' => 36,
9 'membership_type_id' => 60,
6a488035
TO
10 'join_date' => '2009-01-21',
11 'start_date' => '2009-01-21',
12 'end_date' => '2009-12-21',
13 'source' => 'Payment',
14 'is_override' => 1,
37eda84b 15 'status_id' => 37,
fb32de45 16 'custom_1' => 'custom string',
6a488035
TO
17);
18
fb32de45 19try{
20 $result = civicrm_api3('membership', 'update', $params);
21}
22catch (CiviCRM_API3_Exception $e) {
23 // handle error here
24 $errorMessage = $e->getMessage();
25 $errorCode = $e->getErrorCode();
26 $errorData = $e->getExtraParams();
27 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
28}
6a488035 29
fb32de45 30return $result;
6a488035
TO
31}
32
fb32de45 33/**
6a488035
TO
34 * Function returns array of result expected from previous function
35 */
36function membership_update_expectedresult(){
37
53ca8fd7 38 $expectedResult = array(
6a488035
TO
39 'is_error' => 0,
40 'version' => 3,
41 'count' => 1,
42 'id' => 1,
53ca8fd7 43 'values' => array(
44 '1' => array(
6a488035 45 'id' => '1',
37eda84b 46 'contact_id' => '36',
47 'membership_type_id' => '60',
6a488035 48 'join_date' => '20090121000000',
9f1b81e0 49 'start_date' => '2013-07-29 00:00:00',
50 'end_date' => '2013-08-04 00:00:00',
6a488035 51 'source' => 'Payment',
37eda84b 52 'status_id' => '37',
6a488035
TO
53 'is_override' => '1',
54 'owner_membership_id' => '',
55 'max_related' => '',
37eda84b 56 'is_test' => 0,
6a488035
TO
57 'is_pay_later' => '',
58 'contribution_recur_id' => '',
59 'campaign_id' => '',
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* testUpdateWithCustom 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*/