Merge pull request #1260 from aadityawalawalkar/CRM-12994
[civicrm-core.git] / tests / phpunit / api / v3 / MembershipTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 * Test APIv3 civicrm_membership functions
30 *
31 * @package CiviCRM_APIv3
32 * @subpackage API_Member
33 */
34
35
36 require_once 'CiviTest/CiviUnitTestCase.php';
37
38 class api_v3_MembershipTest extends CiviUnitTestCase {
39 protected $_apiversion;
40 protected $_contactID;
41 protected $_membershipTypeID;
42 protected $_membershipStatusID;
43 protected $__membershipID;
44 protected $_entity;
45 protected $_params;
46 public $_eNoticeCompliant = TRUE;
47
48 public function setUp() {
49 // Connect to the database
50 parent::setUp();
51 $this->_apiversion = 3;
52 $this->_contactID = $this->individualCreate();
53 $this->_membershipTypeID = $this->membershipTypeCreate($this->_contactID);
54 $this->_membershipStatusID = $this->membershipStatusCreate('test status');
55
56 require_once 'CRM/Member/PseudoConstant.php';
57 CRM_Member_PseudoConstant::membershipType(NULL, TRUE);
58 CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'name', TRUE);
59 CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name');
60
61 $this->_entity = 'Membership';
62 $this->_params = array(
63 'contact_id' => $this->_contactID,
64 'membership_type_id' => $this->_membershipTypeID,
65 'join_date' => '2009-01-21',
66 'start_date' => '2009-01-21',
67 'end_date' => '2009-12-21',
68 'source' => 'Payment',
69 'is_override' => 1,
70 'status_id' => $this->_membershipStatusID,
71 );
72 }
73
74 function tearDown() {
75 $this->quickCleanup(array(
76 'civicrm_membership',
77 'civicrm_membership_payment',
78 'civicrm_membership_log',
79 ),
80 TRUE
81 );
82 $this->membershipStatusDelete($this->_membershipStatusID);
83 $this->membershipTypeDelete(array('id' => $this->_membershipTypeID));
84 $this->contactDelete($this->_contactID);
85
86 }
87
88 /**
89 * Test civicrm_membership_delete()
90 */
91 function testMembershipDelete() {
92 $membershipID = $this->contactMembershipCreate($this->_params);
93 $this->assertDBRowExist('CRM_Member_DAO_Membership', $membershipID);
94 $params = array(
95 'id' => $membershipID
96 );
97 $result = $this->callAPIAndDocument('membership', 'delete', $params, __FUNCTION__, __FILE__);
98 $this->assertDBRowNotExist('CRM_Member_DAO_Membership', $membershipID);
99 }
100
101 function testMembershipDeleteEmpty() {
102 $params = array();
103 $result = $this->callAPIFailure('membership', 'delete', $params);
104 }
105
106 function testMembershipDeleteInvalidID() {
107 $params = array('id' => 'blah');
108 $result = $this->callAPIFailure('membership', 'delete', $params);
109 }
110
111 /**
112 * Test civicrm_membership_delete() with invalid Membership Id
113 */
114 function testMembershipDeleteWithInvalidMembershipId() {
115 $membershipId = 'membership';
116 $result = $this->callAPIFailure('membership', 'delete', $membershipId);
117 }
118
119 /**
120 * All other methods calls MembershipType and MembershipContact
121 * api, but putting simple test methods to control existence of
122 * these methods for backwards compatibility, also verifying basic
123 * behaviour is the same as new methods.
124 */
125 function testContactMembershipsGet() {
126 $this->_membershipID = $this->contactMembershipCreate($this->_params);
127 $params = array();
128 $result = $this->callAPISuccess('membership', 'get', $params);
129 $result = $this->callAPISuccess('Membership', 'Delete', array(
130 'id' => $this->_membershipID,
131 ));
132 }
133
134 /**
135 * Test civicrm_membership_get with params not array.
136 * Gets treated as contact_id, memberships expected.
137 */
138 function testGetWithParamsContactId() {
139 $this->_membershipID = $this->contactMembershipCreate($this->_params);
140 $params = array(
141 'contact_id' => $this->_contactID,
142 );
143 $membership = $this->callAPISuccess('membership', 'get', $params);
144
145 $result = $membership['values'][$this->_membershipID];
146 $this->callAPISuccess('Membership', 'Delete', array(
147 'id' => $this->_membershipID,
148 ));
149 $this->assertEquals($result['contact_id'], $this->_contactID, "In line " . __LINE__);
150 $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID, "In line " . __LINE__);
151 $this->assertEquals($result['status_id'], $this->_membershipStatusID, "In line " . __LINE__);
152 $this->assertEquals($result['join_date'], '2009-01-21', "In line " . __LINE__);
153 $this->assertEquals($result['start_date'], '2009-01-21', "In line " . __LINE__);
154 $this->assertEquals($result['end_date'], '2009-12-21', "In line " . __LINE__);
155 $this->assertEquals($result['source'], 'Payment', "In line " . __LINE__);
156 $this->assertEquals($result['is_override'], 1, "In line " . __LINE__);
157 }
158
159 /**
160 * Test civicrm_membership_get with params not array.
161 * Gets treated as contact_id, memberships expected.
162 */
163 function testGetWithParamsMemberShipTypeId() {
164 $result = $this->callAPISuccess($this->_entity, 'create', $this->_params);
165 $params = array(
166 'membership_type_id' => $this->_membershipTypeID,
167 );
168 $membership = $this->callAPISuccess('membership', 'get', $params);
169 $result = $this->callAPISuccess('Membership', 'Delete', array(
170 'id' => $membership['id'],
171 ));
172 $result = $membership['values'][$membership['id']];
173 $this->assertEquals($result['contact_id'], $this->_contactID, "In line " . __LINE__);
174 $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID, "In line " . __LINE__);
175 $this->assertEquals($result['status_id'], $this->_membershipStatusID, "In line " . __LINE__);
176 $this->assertEquals($result['join_date'], '2009-01-21', "In line " . __LINE__);
177 $this->assertEquals($result['start_date'], '2009-01-21', "In line " . __LINE__);
178 $this->assertEquals($result['end_date'], '2009-12-21', "In line " . __LINE__);
179 $this->assertEquals($result['source'], 'Payment', "In line " . __LINE__);
180 $this->assertEquals($result['is_override'], 1, "In line " . __LINE__);
181 $this->assertEquals($result['id'], $membership['id']);
182 }
183
184 /**
185 * check with complete array + custom field
186 * Note that the test is written on purpose without any
187 * variables specific to participant so it can be replicated into other entities
188 * and / or moved to the automated test suite
189 */
190 function testGetWithParamsMemberShipIdAndCustom() {
191 $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
192
193 $params = $this->_params;
194 $params['custom_' . $ids['custom_field_id']] = "custom string";
195
196 $result = $this->callAPISuccess($this->_entity, 'create', $params);
197
198 $getParams = array('membership_type_id' => $params['membership_type_id']);
199 $check = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__);
200 $this->assertEquals("custom string", $check['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__);
201
202 $result = $this->callAPISuccess('Membership', 'Delete', array(
203 'id' => $result['id'],
204 ));
205 }
206
207 /**
208 * Test civicrm_membership_get with proper params.
209 * Memberships expected.
210 */
211 function testGet() {
212 $membershipID = $this->contactMembershipCreate($this->_params);
213 $params = array(
214 'contact_id' => $this->_contactID,
215 );
216
217 $membership = $this->callAPISuccess('membership', 'get', $params);
218 $result = $membership['values'][$membershipID];
219 $this->callAPISuccess('Membership', 'Delete', array(
220 'id' => $membership['id'],
221 ));
222 $this->assertEquals($result['join_date'], '2009-01-21', "In line " . __LINE__);
223 $this->assertEquals($result['contact_id'], $this->_contactID, "In line " . __LINE__);
224 $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID, "In line " . __LINE__);
225 $this->assertEquals($result['status_id'], $this->_membershipStatusID, "In line " . __LINE__);
226
227 $this->assertEquals($result['start_date'], '2009-01-21', "In line " . __LINE__);
228 $this->assertEquals($result['end_date'], '2009-12-21', "In line " . __LINE__);
229 $this->assertEquals($result['source'], 'Payment', "In line " . __LINE__);
230 $this->assertEquals($result['is_override'], 1, "In line " . __LINE__);
231 }
232
233
234 /**
235 * Test civicrm_membership_get with proper params.
236 * Memberships expected.
237 */
238 function testGetWithId() {
239 $membershipID = $this->contactMembershipCreate($this->_params);
240 $params = array(
241 'contact_id' => $this->_contactID,
242 'id' => $this->__membershipID,
243 'return' => 'id',
244 );
245 $result = $this->callAPISuccess('membership', 'get', $params);
246 $this->assertEquals($membershipID, $result['id']);
247 $params = array(
248 'contact_id' => $this->_contactID,
249 'membership_id' => $this->__membershipID,
250 'return' => 'membership_id',
251 );
252 $result = $this->callAPISuccess('membership', 'get', $params);
253 $this->assertEquals($membershipID, $result['id']);
254 }
255
256 /**
257 * Test civicrm_membership_get for only active.
258 * Memberships expected.
259 */
260 function testGetOnlyActive() {
261 $description = "Demonstrates use of 'filter' active_only' param";
262 $this->_membershipID = $this->contactMembershipCreate($this->_params);
263 $subfile = 'filterIsCurrent';
264 $params = array(
265 'contact_id' => $this->_contactID,
266 'active_only' => 1,
267 );
268
269 $membership = $this->callAPISuccess('membership', 'get', $params);
270 $result = $membership['values'][$this->_membershipID];
271 $this->assertEquals($membership['values'][$this->_membershipID]['status_id'], $this->_membershipStatusID, "In line " . __LINE__);
272 $this->assertEquals($membership['values'][$this->_membershipID]['contact_id'], $this->_contactID, "In line " . __LINE__);
273 $params = array(
274 'contact_id' => $this->_contactID,
275 'filters' => array(
276 'is_current' => 1,
277 ),
278 );
279
280 $membership = $this->callAPIAndDocument('membership', 'get', $params, __FUNCTION__, __FILE__, $description, $subfile);
281 $result = $membership['values'][$this->_membershipID];
282 $this->assertEquals($membership['values'][$this->_membershipID]['status_id'], $this->_membershipStatusID, "In line " . __LINE__);
283 $this->assertEquals($membership['values'][$this->_membershipID]['contact_id'], $this->_contactID, "In line " . __LINE__);
284
285
286 $result = $this->callAPISuccess('Membership', 'Delete', array(
287 'id' => $this->_membershipID,
288 ));
289 }
290
291 /**
292 * Test civicrm_membership_get for non exist contact.
293 * empty Memberships.
294 */
295 function testGetNoContactExists() {
296 $params = array(
297 'contact_id' => 55555,
298 );
299
300 $membership = $this->callAPISuccess('membership', 'get', $params);
301 $this->assertEquals($membership['count'], 0, "In line " . __LINE__);
302 }
303
304 /**
305 * Test civicrm_membership_get with relationship.
306 * get Memberships.
307 */
308 function testGetWithRelationship() {
309 $membershipOrgId = $this->organizationCreate(NULL);
310 $memberContactId = $this->individualCreate(NULL);
311
312 $relTypeParams = array(
313 'name_a_b' => 'Relation 1',
314 'name_b_a' => 'Relation 2',
315 'description' => 'Testing relationship type',
316 'contact_type_a' => 'Organization',
317 'contact_type_b' => 'Individual',
318 'is_reserved' => 1,
319 'is_active' => 1,
320 );
321 $relTypeID = $this->relationshipTypeCreate($relTypeParams);
322
323 $params = array(
324 'name' => 'test General',
325 'duration_unit' => 'year',
326 'duration_interval' => 1,
327 'period_type' => 'rolling',
328 'member_of_contact_id' => $membershipOrgId,
329 'domain_id' => 1,
330 'financial_type_id' => 1,
331 'relationship_type_id' => $relTypeID,
332 'relationship_direction' => 'b_a',
333 'is_active' => 1,
334 );
335 $memType = $this->callAPISuccess('membership_type', 'create', $params);
336
337 $params = array(
338 'contact_id' => $memberContactId,
339 'membership_type_id' => $memType['id'],
340 'join_date' => '2009-01-21',
341 'start_date' => '2009-01-21',
342 'end_date' => '2009-12-21',
343 'source' => 'Payment',
344 'is_override' => 1,
345 'status_id' => $this->_membershipStatusID,
346 );
347 $membershipID = $this->contactMembershipCreate($params);
348
349 $params = array(
350 'contact_id' => $memberContactId,
351 'membership_type_id' => $memType['id'],
352 );
353
354 $result = $this->callAPISuccess('membership', 'get', $params);
355
356 $membership = $result['values'][$membershipID];
357 $this->assertEquals($this->_membershipStatusID, $membership['status_id']);
358 $result = $this->callAPISuccess('Membership', 'Delete', array(
359 'id' => $membership['id'],
360 ));
361 $this->membershipTypeDelete(array('id' => $memType['id']));
362 $this->relationshipTypeDelete($relTypeID);
363 $this->contactDelete($membershipOrgId);
364 $this->contactDelete($memberContactId);
365 }
366
367 ///////////////// civicrm_membership_create methods
368
369 /**
370 * Test civicrm_contact_memberships_create with empty params.
371 * Error expected.
372 */
373 function testCreateWithEmptyParams() {
374 $params = array();
375 $result = $this->callAPIFailure('membership', 'create', $params);
376 }
377
378 /**
379 * If is_overide is passed in status must also be passed in
380 */
381 function testCreateOverrideNoStatus() {
382 $params = $this->_params;
383 unset($params['status_id']);
384 $result = $this->callAPIFailure('membership', 'create', $params);
385 }
386
387 function testMembershipCreateMissingRequired() {
388 $params = array(
389 'membership_type_id' => '1',
390 'join_date' => '2006-01-21',
391 'start_date' => '2006-01-21',
392 'end_date' => '2006-12-21',
393 'source' => 'Payment',
394 'status_id' => '2',
395 );
396
397 $result = $this->callAPIFailure('membership', 'create', $params);
398 }
399
400 function testMembershipCreate() {
401 $params = array(
402 'contact_id' => $this->_contactID,
403 'membership_type_id' => $this->_membershipTypeID,
404 'join_date' => '2006-01-21',
405 'start_date' => '2006-01-21',
406 'end_date' => '2006-12-21',
407 'source' => 'Payment',
408 'is_override' => 1,
409 'status_id' => $this->_membershipStatusID,
410 );
411
412 $result = $this->callAPIAndDocument('membership', 'create', $params, __FUNCTION__, __FILE__);
413 $this->getAndCheck($params, $result['id'], $this->_entity);
414 $this->assertNotNull($result['id']);
415 $this->assertEquals($this->_contactID, $result['values'][$result['id']]['contact_id'], " in line " . __LINE__);
416 $this->assertEquals($result['id'], $result['values'][$result['id']]['id'], " in line " . __LINE__);
417 }
418 /*
419 * Check for useful message if contact doesn't exist
420 */
421 function testMembershipCreateWithInvalidContact() {
422 $params = array(
423 'contact_id' => 999,
424 'membership_type_id' => $this->_membershipTypeID,
425 'join_date' => '2006-01-21',
426 'start_date' => '2006-01-21',
427 'end_date' => '2006-12-21',
428 'source' => 'Payment',
429 'is_override' => 1,
430 'status_id' => $this->_membershipStatusID,
431 );
432
433 $result = $this->callAPIFailure('membership', 'create', $params,
434 'contact_id is not valid : 999'
435 );
436 }
437 function testMembershipCreateWithInvalidStatus() {
438 $params = $this->_params;
439 $params['status_id'] = 999;
440 $result = $this->callAPIFailure('membership', 'create', $params,
441 "'999' is not a valid option for field status_id"
442 );
443 }
444
445 function testMembershipCreateWithInvalidType() {
446 $params = $this->_params;
447 $params['membership_type_id'] = 999;
448
449 $result = $this->callAPIFailure('membership', 'create', $params,
450 "'999' is not a valid option for field membership_type_id"
451 );
452 }
453
454 /**
455 * check with complete array + custom field
456 * Note that the test is written on purpose without any
457 * variables specific to participant so it can be replicated into other entities
458 * and / or moved to the automated test suite
459 */
460 function testCreateWithCustom() {
461 $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
462
463 $params = $this->_params;
464 $params['custom_' . $ids['custom_field_id']] = "custom string";
465
466 $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
467 $check = $this->callAPISuccess($this->_entity, 'get', array('id' => $result['id'], 'contact_id' => $this->_contactID));
468 $this->assertEquals("custom string", $check['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__);
469 }
470
471 /**
472 * Test civicrm_contact_memberships_create with membership id (edit
473 * membership).
474 * success expected.
475 */
476 function testMembershipCreateWithId() {
477 $membershipID = $this->contactMembershipCreate($this->_params);
478 $params = array(
479 'id' => $membershipID,
480 'contact_id' => $this->_contactID,
481 'membership_type_id' => $this->_membershipTypeID,
482 'join_date' => '2006-01-21',
483 'start_date' => '2006-01-21',
484 'end_date' => '2006-12-21',
485 'source' => 'Payment',
486 'is_override' => 1,
487 'status_id' => $this->_membershipStatusID,
488 );
489
490 $result = $this->callAPISuccess('membership', 'create', $params);
491 $this->callAPISuccess('Membership', 'Delete', array(
492 'id' => $result['id'],
493 ));
494 $this->assertEquals($result['id'], $membershipID, "in line " . __LINE__);
495 }
496
497 /**
498 * Test civicrm_contact_memberships_create with membership id (edit
499 * membership).
500 * success expected.
501 */
502 function testMembershipCreateUpdateWithIdNoContact() {
503 $membershipID = $this->contactMembershipCreate($this->_params);
504 $params = array(
505 'id' => $membershipID,
506 'membership_type_id' => $this->_membershipTypeID,
507 'contact_id' => $this->_contactID,
508 'join_date' => '2006-01-21',
509 'start_date' => '2006-01-21',
510 'end_date' => '2006-12-21',
511 'source' => 'Payment',
512 'is_override' => 1,
513 'status_id' => $this->_membershipStatusID,
514 );
515
516 $result = $this->callAPISuccess('membership', 'create', $params);
517 $this->callAPISuccess('Membership', 'Delete', array(
518 'id' => $result['id'],
519 ));
520
521 $this->assertEquals($result['id'], $membershipID, "in line " . __LINE__);
522 }
523
524 /**
525 * Test civicrm_contact_memberships_create with membership id (edit
526 * membership).
527 * success expected.
528 */
529 function testMembershipCreateUpdateWithIdNoDates() {
530 $membershipID = $this->contactMembershipCreate($this->_params);
531 $params = array(
532 'id' => $membershipID,
533 'contact_id' => $this->_contactID,
534 'membership_type_id' => $this->_membershipTypeID,
535 'source' => 'Payment',
536 'is_override' => 1,
537 'status_id' => $this->_membershipStatusID,
538 );
539
540 $result = $this->callAPISuccess('membership', 'create', $params);
541 $this->callAPISuccess('Membership', 'Delete', array(
542 'id' => $result['id'],
543 ));
544 $this->assertEquals($result['id'], $membershipID, "in line " . __LINE__);
545 }
546
547 /**
548 * Test civicrm_contact_memberships_create with membership id (edit
549 * membership).
550 * success expected.
551 */
552 function testMembershipCreateUpdateWithIdNoDatesNoType() {
553 $membershipID = $this->contactMembershipCreate($this->_params);
554 $params = array(
555 'id' => $membershipID,
556 'source' => 'not much here',
557 'contact_id' => $this->_contactID,
558 'is_override' => 1,
559 'status_id' => $this->_membershipStatusID,
560 );
561
562 $result = $this->callAPISuccess('membership', 'create', $params);
563 $this->callAPISuccess('Membership', 'Delete', array(
564 'id' => $result['id'],
565 ));
566 $this->assertEquals($result['id'], $membershipID, "in line " . __LINE__);
567 }
568
569 /**
570 * Test civicrm_contact_memberships_create with membership id (edit
571 * membership).
572 * success expected.
573 */
574 function testMembershipCreateUpdateWithIDAndSource() {
575 $membershipID = $this->contactMembershipCreate($this->_params);
576 $params = array(
577 'id' => $membershipID,
578 'source' => 'changed',
579 'contact_id' => $this->_contactID,
580 'status_id' => $this->_membershipStatusID, 'membership_type_id' => $this->_membershipTypeID,
581 'skipStatusCal' => 1,
582 );
583 $result = $this->callAPISuccess('membership', 'create', $params);
584 $this->assertEquals($result['id'], $membershipID, "in line " . __LINE__);
585 $this->callAPISuccess('Membership', 'Delete', array(
586 'id' => $result['id'],
587 ));
588 }
589
590 /**
591 * change custom field using update
592 */
593 function testUpdateWithCustom() {
594 $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
595
596 $params = $this->_params;
597 $params['custom_' . $ids['custom_field_id']] = "custom string";
598 $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
599 $result = $this->callAPISuccess($this->_entity, 'create', array('id' => $result['id'], 'custom_' . $ids['custom_field_id'] => "new custom"));
600 $check = $this->callAPISuccess($this->_entity, 'get', array('id' => $result['id'], 'contact_id' => $this->_contactID));
601
602 $this->assertEquals("new custom", $check['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__);
603 $delete = $this->callAPISuccess('Membership', 'Delete', array(
604 'id' => $check['id'],
605 ));
606
607 $this->customFieldDelete($ids['custom_field_id']);
608 $this->customGroupDelete($ids['custom_group_id']);
609 }
610
611 /**
612 * Test civicrm_contact_memberships_create Invalid membership data
613 * Error expected.
614 */
615 function testMembershipCreateInvalidMemData() {
616 //membership_contact_id as string
617 $params = array(
618 'membership_contact_id' => 'Invalid',
619 'membership_type_id' => $this->_membershipTypeID,
620 'join_date' => '2011-01-21',
621 'start_date' => '2010-01-21',
622 'end_date' => '2008-12-21',
623 'source' => 'Payment',
624 'is_override' => 1,
625 'status_id' => $this->_membershipStatusID, );
626
627 $result = $this->callAPIFailure('membership', 'create', $params);
628
629 //membership_contact_id which is no in contact table
630 $params['membership_contact_id'] = 999;
631 $result = $this->callAPIFailure('membership', 'create', $params);
632
633 //invalid join date
634 unset($params['membership_contact_id']);
635 $params['join_date'] = "invalid";
636 $result = $this->callAPIFailure('Membership', 'Create', $params);
637 }
638
639 /**
640 * Test civicrm_contact_memberships_create with membership_contact_id
641 * membership).
642 * Success expected.
643 */
644 function testMembershipCreateWithMemContact() {
645 $params = array(
646 'membership_contact_id' => $this->_contactID,
647 'membership_type_id' => $this->_membershipTypeID,
648 'join_date' => '2011-01-21',
649 'start_date' => '2010-01-21',
650 'end_date' => '2008-12-21',
651 'source' => 'Payment',
652 'is_override' => 1,
653 'status_id' => $this->_membershipStatusID,
654 );
655
656 $result = $this->callAPISuccess('membership', 'create', $params);
657
658 $result = $this->callAPISuccess('Membership', 'Delete', array(
659 'id' => $result['id'],
660 ));
661 }
662
663 ///////////////// civicrm_membership_delete methods
664 }
665