3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
29 * Test APIv3 civicrm_membership functions
31 * @package CiviCRM_APIv3
32 * @subpackage API_Member
36 require_once 'CiviTest/CiviUnitTestCase.php';
39 * Class api_v3_MembershipTest
41 class api_v3_MembershipTest
extends CiviUnitTestCase
{
42 protected $_apiversion;
43 protected $_contactID;
44 protected $_membershipID;
45 protected $_membershipID2;
46 protected $_membershipID3;
47 protected $_membershipTypeID;
48 protected $_membershipTypeID2;
49 protected $_membershipStatusID;
54 public function setUp() {
55 // Connect to the database.
57 $this->_apiversion
= 3;
58 $this->_contactID
= $this->individualCreate();
59 $this->_membershipTypeID
= $this->membershipTypeCreate(array('member_of_contact_id' => $this->_contactID
));
60 $this->_membershipTypeID2
= $this->membershipTypeCreate(array(
61 'period_type' => 'fixed',
63 'fixed_period_start_day' => '301',
65 'fixed_period_rollover_day' => '1111',
67 $this->_membershipStatusID
= $this->membershipStatusCreate('test status');
69 CRM_Member_PseudoConstant
::membershipType(NULL, TRUE);
70 CRM_Member_PseudoConstant
::membershipStatus(NULL, NULL, 'name', TRUE);
71 CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, TRUE, 'name');
73 $this->_entity
= 'Membership';
74 $this->_params
= array(
75 'contact_id' => $this->_contactID
,
76 'membership_type_id' => $this->_membershipTypeID
,
77 'join_date' => '2009-01-21',
78 'start_date' => '2009-01-21',
79 'end_date' => '2009-12-21',
80 'source' => 'Payment',
82 'status_id' => $this->_membershipStatusID
,
86 public function tearDown() {
87 $this->quickCleanup(array(
89 'civicrm_membership_payment',
90 'civicrm_membership_log',
94 $this->membershipStatusDelete($this->_membershipStatusID
);
95 $this->membershipTypeDelete(array('id' => $this->_membershipTypeID2
));
96 $this->membershipTypeDelete(array('id' => $this->_membershipTypeID
));
97 $this->contactDelete($this->_contactID
);
102 * Test membership deletion.
104 public function testMembershipDelete() {
105 $membershipID = $this->contactMembershipCreate($this->_params
);
106 $this->assertDBRowExist('CRM_Member_DAO_Membership', $membershipID);
108 'id' => $membershipID,
110 $this->callAPIAndDocument('membership', 'delete', $params, __FUNCTION__
, __FILE__
);
111 $this->assertDBRowNotExist('CRM_Member_DAO_Membership', $membershipID);
114 public function testMembershipDeleteEmpty() {
115 $this->callAPIFailure('membership', 'delete', array());
118 public function testMembershipDeleteInvalidID() {
119 $this->callAPIFailure('membership', 'delete', array('id' => 'blah'));
123 * Test civicrm_membership_delete() with invalid Membership Id.
125 public function testMembershipDeleteWithInvalidMembershipId() {
126 $membershipId = 'membership';
127 $this->callAPIFailure('membership', 'delete', $membershipId);
131 * Test membership get.
133 public function testContactMembershipsGet() {
134 $this->_membershipID
= $this->contactMembershipCreate($this->_params
);
135 $this->callAPISuccess('membership', 'get', array());
136 $this->callAPISuccess('Membership', 'Delete', array('id' => $this->_membershipID
));
140 * Test civicrm_membership_get with params not array.
142 * Gets treated as contact_id, memberships expected.
144 public function testGetWithParamsContactId() {
145 $this->_membershipID
= $this->contactMembershipCreate($this->_params
);
147 'contact_id' => $this->_contactID
,
149 $membership = $this->callAPISuccess('membership', 'get', $params);
151 $result = $membership['values'][$this->_membershipID
];
152 $this->callAPISuccess('Membership', 'Delete', array(
153 'id' => $this->_membershipID
,
155 $this->assertEquals($result['contact_id'], $this->_contactID
, "In line " . __LINE__
);
156 $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID
, "In line " . __LINE__
);
157 $this->assertEquals($result['status_id'], $this->_membershipStatusID
, "In line " . __LINE__
);
158 $this->assertEquals($result['join_date'], '2009-01-21', "In line " . __LINE__
);
159 $this->assertEquals($result['start_date'], '2009-01-21', "In line " . __LINE__
);
160 $this->assertEquals($result['end_date'], '2009-12-21', "In line " . __LINE__
);
161 $this->assertEquals($result['source'], 'Payment', "In line " . __LINE__
);
162 $this->assertEquals($result['is_override'], 1, "In line " . __LINE__
);
166 * Test civicrm_membership_get with params not array.
168 * Gets treated as contact_id, memberships expected.
170 public function testGetInSyntax() {
171 $this->_membershipID
= $this->contactMembershipCreate($this->_params
);
172 $this->_membershipID2
= $this->contactMembershipCreate($this->_params
);
173 $this->_membershipID3
= $this->contactMembershipCreate($this->_params
);
175 'id' => array('IN' => array($this->_membershipID
, $this->_membershipID3
)),
177 $membership = $this->callAPISuccess('membership', 'get', $params);
178 $this->assertEquals(2, $membership['count']);
179 $this->assertEquals(array($this->_membershipID
, $this->_membershipID3
), array_keys($membership['values']));
181 'id' => array('NOT IN' => array($this->_membershipID
, $this->_membershipID3
)),
183 $membership = $this->callAPISuccess('membership', 'get', $params);
184 $this->assertEquals(1, $membership['count']);
185 $this->assertEquals(array($this->_membershipID2
), array_keys($membership['values']));
189 * Test civicrm_membership_get with params not array.
190 * Gets treated as contact_id, memberships expected.
192 public function testGetInSyntaxOnContactID() {
193 $this->_membershipID
= $this->contactMembershipCreate($this->_params
);
194 $contact2 = $this->individualCreate();
195 $contact3 = $this->individualCreate(array('first_name' => 'Scout', 'last_name' => 'Canine'));
196 $this->_membershipID2
= $this->contactMembershipCreate(array_merge($this->_params
, array('contact_id' => $contact2)));
197 $this->_membershipID3
= $this->contactMembershipCreate(array_merge($this->_params
, array('contact_id' => $contact3)));
199 'contact_id' => array('IN' => array($this->_contactID
, $contact3)),
201 $membership = $this->callAPISuccess('membership', 'get', $params);
202 $this->assertEquals(2, $membership['count']);
203 $this->assertEquals(array($this->_membershipID
, $this->_membershipID3
), array_keys($membership['values']));
205 'contact_id' => array('NOT IN' => array($this->_contactID
, $contact3)),
207 $membership = $this->callAPISuccess('membership', 'get', $params);
208 $this->assertEquals(1, $membership['count']);
209 $this->assertEquals(array($this->_membershipID2
), array_keys($membership['values']));
213 * Test civicrm_membership_get with params not array.
214 * Gets treated as contact_id, memberships expected.
216 public function testGetWithParamsMemberShipTypeId() {
217 $this->callAPISuccess($this->_entity
, 'create', $this->_params
);
219 'membership_type_id' => $this->_membershipTypeID
,
221 $membership = $this->callAPISuccess('membership', 'get', $params);
222 $this->callAPISuccess('Membership', 'Delete', array(
223 'id' => $membership['id'],
225 $result = $membership['values'][$membership['id']];
226 $this->assertEquals($result['contact_id'], $this->_contactID
, "In line " . __LINE__
);
227 $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID
, "In line " . __LINE__
);
228 $this->assertEquals($result['status_id'], $this->_membershipStatusID
, "In line " . __LINE__
);
229 $this->assertEquals($result['join_date'], '2009-01-21', "In line " . __LINE__
);
230 $this->assertEquals($result['start_date'], '2009-01-21', "In line " . __LINE__
);
231 $this->assertEquals($result['end_date'], '2009-12-21', "In line " . __LINE__
);
232 $this->assertEquals($result['source'], 'Payment', "In line " . __LINE__
);
233 $this->assertEquals($result['is_override'], 1, "In line " . __LINE__
);
234 $this->assertEquals($result['id'], $membership['id']);
238 * Test civicrm_membership_get with params not array.
239 * Gets treated as contact_id, memberships expected.
241 public function testGetWithParamsMemberShipTypeIdContactID() {
242 $params = $this->_params
;
243 $this->callAPISuccess($this->_entity
, 'create', $params);
244 $params['membership_type_id'] = $this->_membershipTypeID2
;
245 $this->callAPISuccess($this->_entity
, 'create', $params);
246 $this->callAPISuccessGetCount('membership', array('contact_id' => $this->_contactID
), 2);
248 'membership_type_id' => $this->_membershipTypeID
,
249 'contact_id' => $this->_contactID
,
251 $result = $this->callAPISuccess('membership', 'getsingle', $params);
252 $this->assertEquals($result['contact_id'], $this->_contactID
);
253 $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID
);
256 'membership_type_id' => $this->_membershipTypeID2
,
257 'contact_id' => $this->_contactID
,
259 $result = $this->callAPISuccess('membership', 'getsingle', $params);
260 $this->assertEquals($result['contact_id'], $this->_contactID
);
261 $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID2
);
265 * Check with complete array + custom field
266 * Note that the test is written on purpose without any
267 * variables specific to participant so it can be replicated into other entities
268 * and / or moved to the automated test suite
270 public function testGetWithParamsMemberShipIdAndCustom() {
271 $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__
, __FILE__
);
273 $params = $this->_params
;
274 $params['custom_' . $ids['custom_field_id']] = "custom string";
276 $result = $this->callAPISuccess($this->_entity
, 'create', $params);
278 $getParams = array('membership_type_id' => $params['membership_type_id']);
279 $check = $this->callAPIAndDocument($this->_entity
, 'get', $getParams, __FUNCTION__
, __FILE__
);
280 $this->assertEquals("custom string", $check['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__
);
282 $this->callAPISuccess('Membership', 'Delete', array(
283 'id' => $result['id'],
288 * Test civicrm_membership_get with proper params.
289 * Memberships expected.
291 public function testGet() {
292 $membershipID = $this->contactMembershipCreate($this->_params
);
294 'contact_id' => $this->_contactID
,
297 $membership = $this->callAPISuccess('membership', 'get', $params);
298 $result = $membership['values'][$membershipID];
299 $this->callAPISuccess('Membership', 'Delete', array(
300 'id' => $membership['id'],
302 $this->assertEquals($result['join_date'], '2009-01-21', "In line " . __LINE__
);
303 $this->assertEquals($result['contact_id'], $this->_contactID
, "In line " . __LINE__
);
304 $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID
, "In line " . __LINE__
);
305 $this->assertEquals($result['status_id'], $this->_membershipStatusID
, "In line " . __LINE__
);
307 $this->assertEquals($result['start_date'], '2009-01-21', "In line " . __LINE__
);
308 $this->assertEquals($result['end_date'], '2009-12-21', "In line " . __LINE__
);
309 $this->assertEquals($result['source'], 'Payment', "In line " . __LINE__
);
310 $this->assertEquals($result['is_override'], 1, "In line " . __LINE__
);
315 * Test civicrm_membership_get with proper params.
316 * Memberships expected.
318 public function testGetWithId() {
319 $membershipID = $this->contactMembershipCreate($this->_params
);
321 'contact_id' => $this->_contactID
,
322 'id' => $this->_membershipID
,
325 $result = $this->callAPISuccess('membership', 'get', $params);
326 $this->assertEquals($membershipID, $result['id']);
328 'contact_id' => $this->_contactID
,
329 'membership_id' => $this->_membershipID
,
330 'return' => 'membership_id',
332 $result = $this->callAPISuccess('membership', 'get', $params);
333 $this->assertEquals($membershipID, $result['id']);
337 * Test civicrm_membership_get for only active.
338 * Memberships expected.
340 public function testGetOnlyActive() {
341 $description = "Demonstrates use of 'filter' active_only' param";
342 $this->_membershipID
= $this->contactMembershipCreate($this->_params
);
343 $subfile = 'filterIsCurrent';
345 'contact_id' => $this->_contactID
,
349 $membership = $this->callAPISuccess('membership', 'get', $params);
350 $this->assertEquals($membership['values'][$this->_membershipID
]['status_id'], $this->_membershipStatusID
);
351 $this->assertEquals($membership['values'][$this->_membershipID
]['contact_id'], $this->_contactID
);
353 'contact_id' => $this->_contactID
,
359 $membership = $this->callAPIAndDocument('membership', 'get', $params, __FUNCTION__
, __FILE__
, $description, $subfile);
360 $this->assertEquals($membership['values'][$this->_membershipID
]['status_id'], $this->_membershipStatusID
);
361 $this->assertEquals($membership['values'][$this->_membershipID
]['contact_id'], $this->_contactID
);
363 $this->callAPISuccess('Membership', 'Delete', array('id' => $this->_membershipID
));
367 * Test civicrm_membership_get for non exist contact.
370 public function testGetNoContactExists() {
372 'contact_id' => 55555,
375 $membership = $this->callAPISuccess('membership', 'get', $params);
376 $this->assertEquals($membership['count'], 0, "In line " . __LINE__
);
380 * Test civicrm_membership_get with relationship.
383 public function testGetWithRelationship() {
384 $membershipOrgId = $this->organizationCreate(NULL);
385 $memberContactId = $this->individualCreate();
387 $relTypeParams = array(
388 'name_a_b' => 'Relation 1',
389 'name_b_a' => 'Relation 2',
390 'description' => 'Testing relationship type',
391 'contact_type_a' => 'Organization',
392 'contact_type_b' => 'Individual',
396 $relTypeID = $this->relationshipTypeCreate($relTypeParams);
399 'name' => 'test General',
400 'duration_unit' => 'year',
401 'duration_interval' => 1,
402 'period_type' => 'rolling',
403 'member_of_contact_id' => $membershipOrgId,
405 'financial_type_id' => 1,
406 'relationship_type_id' => $relTypeID,
407 'relationship_direction' => 'b_a',
410 $memType = $this->callAPISuccess('membership_type', 'create', $params);
413 'contact_id' => $memberContactId,
414 'membership_type_id' => $memType['id'],
415 'join_date' => '2009-01-21',
416 'start_date' => '2009-01-21',
417 'end_date' => '2009-12-21',
418 'source' => 'Payment',
420 'status_id' => $this->_membershipStatusID
,
422 $membershipID = $this->contactMembershipCreate($params);
425 'contact_id' => $memberContactId,
426 'membership_type_id' => $memType['id'],
429 $result = $this->callAPISuccess('membership', 'get', $params);
431 $membership = $result['values'][$membershipID];
432 $this->assertEquals($this->_membershipStatusID
, $membership['status_id']);
433 $this->callAPISuccess('Membership', 'Delete', array(
434 'id' => $membership['id'],
436 $this->membershipTypeDelete(array('id' => $memType['id']));
437 $this->relationshipTypeDelete($relTypeID);
438 $this->contactDelete($membershipOrgId);
439 $this->contactDelete($memberContactId);
443 * Test civicrm_membership_create with relationships.
444 * create/get Memberships.
446 * Test suite for CRM-14758: API ( contact, create ) does not always create related membership
447 * and max_related property for Membership_Type and Membership entities
449 public function testCreateWithRelationship() {
450 // Create membership type: inherited through employment, max_related = 2
452 'name_a_b' => 'Employee of',
454 $result = $this->callAPISuccess('relationship_type', 'get', $params);
455 $relationshipTypeId = $result['id'];
456 $membershipOrgId = $this->organizationCreate();
458 'name' => 'Corporate Membership',
459 'duration_unit' => 'year',
460 'duration_interval' => 1,
461 'period_type' => 'rolling',
462 'member_of_contact_id' => $membershipOrgId,
464 'financial_type_id' => 1,
465 'relationship_type_id' => $relationshipTypeId,
466 'relationship_direction' => 'b_a',
470 $result = $this->callAPISuccess('membership_type', 'create', $params);
471 $membershipTypeId = $result['id'];
473 // Create employer and first employee
474 $employerId[0] = $this->organizationCreate(array(), 1);
475 $memberContactId[0] = $this->individualCreate(array('employer_id' => $employerId[0]), 0);
477 // Create organization's membership
479 'contact_id' => $employerId[0],
480 'membership_type_id' => $membershipTypeId,
481 'source' => 'Test suite',
482 'start_date' => date('Y-m-d'),
483 'end_date' => "+1 year",
485 $OrganizationMembershipID = $this->contactMembershipCreate($params);
487 // Check that the employee inherited the membership
489 'contact_id' => $memberContactId[0],
490 'membership_type_id' => $membershipTypeId,
493 $result = $this->callAPISuccess('membership', 'get', $params);
495 $this->assertEquals(1, $result['count']);
496 $result = $result['values'][$result['id']];
497 $this->assertEquals($OrganizationMembershipID, $result['owner_membership_id']);
499 // Create second employee
500 $memberContactId[1] = $this->individualCreate(array('employer_id' => $employerId[0]), 1);
502 // Check that the employee inherited the membership
504 'contact_id' => $memberContactId[1],
505 'membership_type_id' => $membershipTypeId,
507 $result = $this->callAPISuccess('membership', 'get', $params);
508 // If it fails here CRM-14758 is not fixed
509 $this->assertEquals(1, $result['count']);
510 $result = $result['values'][$result['id']];
511 $this->assertEquals($OrganizationMembershipID, $result['owner_membership_id']);
513 // Create third employee
514 $memberContactId[2] = $this->individualCreate(array('employer_id' => $employerId[0]), 2);
516 // Check that employee does NOT inherit the membership (max_related = 2)
518 'contact_id' => $memberContactId[2],
519 'membership_type_id' => $membershipTypeId,
521 $result = $this->callAPISuccess('membership', 'get', $params);
522 $this->assertEquals(0, $result['count']);
524 // Increase max_related for the employer's membership
526 'id' => $OrganizationMembershipID,
529 $this->contactMembershipCreate($params);
531 // Check that the employee inherited the membership
533 'contact_id' => $memberContactId[2],
534 'membership_type_id' => $membershipTypeId,
536 $result = $this->callAPISuccess('membership', 'get', $params);
537 $this->assertEquals(1, $result['count']);
538 $result = $result['values'][$result['id']];
539 $this->assertEquals($OrganizationMembershipID, $result['owner_membership_id']);
541 // First employee moves to a new job
542 $employerId[1] = $this->organizationCreate(array(), 2);
544 'id' => $memberContactId[0],
545 'employer_id' => $employerId[1],
547 $this->callAPISuccess('contact', 'create', $params);
549 // Check that employee does NO LONGER inherit the membership
551 'contact_id' => $memberContactId[0],
552 'membership_type_id' => $membershipTypeId,
554 $result = $this->callAPISuccess('membership', 'get', $params);
555 $this->assertEquals(0, $result['count']);
557 // Tear down - reverse of creation to be safe
558 $this->contactDelete($memberContactId[2]);
559 $this->contactDelete($memberContactId[1]);
560 $this->contactDelete($memberContactId[0]);
561 $this->contactDelete($employerId[1]);
562 $this->contactDelete($employerId[0]);
563 $this->membershipTypeDelete(array('id' => $membershipTypeId));
564 $this->contactDelete($membershipOrgId);
568 * We are checking for no enotices + only id & end_date returned
570 public function testMembershipGetWithReturn() {
571 $this->contactMembershipCreate($this->_params
);
572 $result = $this->callAPISuccess('membership', 'get', array('return' => 'end_date'));
573 foreach ($result['values'] as $membership) {
574 $this->assertEquals(array('id', 'end_date'), array_keys($membership));
577 ///////////////// civicrm_membership_create methods
580 * Test civicrm_contact_memberships_create with empty params.
583 public function testCreateWithEmptyParams() {
585 $this->callAPIFailure('membership', 'create', $params);
589 * If is_overide is passed in status must also be passed in
591 public function testCreateOverrideNoStatus() {
592 $params = $this->_params
;
593 unset($params['status_id']);
594 $this->callAPIFailure('membership', 'create', $params);
597 public function testMembershipCreateMissingRequired() {
599 'membership_type_id' => '1',
600 'join_date' => '2006-01-21',
601 'start_date' => '2006-01-21',
602 'end_date' => '2006-12-21',
603 'source' => 'Payment',
607 $this->callAPIFailure('membership', 'create', $params);
610 public function testMembershipCreate() {
612 'contact_id' => $this->_contactID
,
613 'membership_type_id' => $this->_membershipTypeID
,
614 'join_date' => '2006-01-21',
615 'start_date' => '2006-01-21',
616 'end_date' => '2006-12-21',
617 'source' => 'Payment',
619 'status_id' => $this->_membershipStatusID
,
622 $result = $this->callAPIAndDocument('membership', 'create', $params, __FUNCTION__
, __FILE__
);
623 $this->getAndCheck($params, $result['id'], $this->_entity
);
624 $this->assertNotNull($result['id']);
625 $this->assertEquals($this->_contactID
, $result['values'][$result['id']]['contact_id'], " in line " . __LINE__
);
626 $this->assertEquals($result['id'], $result['values'][$result['id']]['id'], " in line " . __LINE__
);
630 * Check for useful message if contact doesn't exist
632 public function testMembershipCreateWithInvalidContact() {
635 'membership_type_id' => $this->_membershipTypeID
,
636 'join_date' => '2006-01-21',
637 'start_date' => '2006-01-21',
638 'end_date' => '2006-12-21',
639 'source' => 'Payment',
641 'status_id' => $this->_membershipStatusID
,
644 $this->callAPIFailure('membership', 'create', $params,
645 'contact_id is not valid : 999'
649 public function testMembershipCreateWithInvalidStatus() {
650 $params = $this->_params
;
651 $params['status_id'] = 999;
652 $this->callAPIFailure('membership', 'create', $params,
653 "'999' is not a valid option for field status_id"
657 public function testMembershipCreateWithInvalidType() {
658 $params = $this->_params
;
659 $params['membership_type_id'] = 999;
661 $this->callAPIFailure('membership', 'create', $params,
662 "'999' is not a valid option for field membership_type_id"
667 * Check with complete array + custom field
668 * Note that the test is written on purpose without any
669 * variables specific to participant so it can be replicated into other entities
670 * and / or moved to the automated test suite
672 public function testCreateWithCustom() {
673 $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__
, __FILE__
);
675 $params = $this->_params
;
676 $params['custom_' . $ids['custom_field_id']] = "custom string";
678 $result = $this->callAPIAndDocument($this->_entity
, 'create', $params, __FUNCTION__
, __FILE__
);
679 $check = $this->callAPISuccess($this->_entity
, 'get', array(
680 'id' => $result['id'],
681 'contact_id' => $this->_contactID
,
683 $this->assertEquals("custom string", $check['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__
);
687 * Test civicrm_contact_memberships_create with membership id (edit
691 public function testMembershipCreateWithId() {
692 $membershipID = $this->contactMembershipCreate($this->_params
);
694 'id' => $membershipID,
695 'contact_id' => $this->_contactID
,
696 'membership_type_id' => $this->_membershipTypeID
,
697 'join_date' => '2006-01-21',
698 'start_date' => '2006-01-21',
699 'end_date' => '2006-12-21',
700 'source' => 'Payment',
702 'status_id' => $this->_membershipStatusID
,
705 $result = $this->callAPISuccess('membership', 'create', $params);
706 $this->callAPISuccess('Membership', 'Delete', array(
707 'id' => $result['id'],
709 $this->assertEquals($result['id'], $membershipID, "in line " . __LINE__
);
713 * Test civicrm_contact_memberships_create with membership id (edit
717 public function testMembershipCreateUpdateWithIdNoContact() {
718 $membershipID = $this->contactMembershipCreate($this->_params
);
720 'id' => $membershipID,
721 'membership_type_id' => $this->_membershipTypeID
,
722 'contact_id' => $this->_contactID
,
723 'join_date' => '2006-01-21',
724 'start_date' => '2006-01-21',
725 'end_date' => '2006-12-21',
726 'source' => 'Payment',
728 'status_id' => $this->_membershipStatusID
,
731 $result = $this->callAPISuccess('membership', 'create', $params);
732 $this->callAPISuccess('Membership', 'Delete', array(
733 'id' => $result['id'],
736 $this->assertEquals($result['id'], $membershipID, "in line " . __LINE__
);
740 * Test civicrm_contact_memberships_create with membership id (edit
744 public function testMembershipCreateUpdateWithIdNoDates() {
745 $membershipID = $this->contactMembershipCreate($this->_params
);
747 'id' => $membershipID,
748 'contact_id' => $this->_contactID
,
749 'membership_type_id' => $this->_membershipTypeID
,
750 'source' => 'Payment',
752 'status_id' => $this->_membershipStatusID
,
755 $result = $this->callAPISuccess('membership', 'create', $params);
756 $this->callAPISuccess('Membership', 'Delete', array(
757 'id' => $result['id'],
759 $this->assertEquals($result['id'], $membershipID, "in line " . __LINE__
);
763 * Test civicrm_contact_memberships_create with membership id (edit
767 public function testMembershipCreateUpdateWithIdNoDatesNoType() {
768 $membershipID = $this->contactMembershipCreate($this->_params
);
770 'id' => $membershipID,
771 'source' => 'not much here',
772 'contact_id' => $this->_contactID
,
774 'status_id' => $this->_membershipStatusID
,
777 $result = $this->callAPISuccess('membership', 'create', $params);
778 $this->callAPISuccess('Membership', 'Delete', array(
779 'id' => $result['id'],
781 $this->assertEquals($result['id'], $membershipID, "in line " . __LINE__
);
785 * Test civicrm_contact_memberships_create with membership id (edit
789 public function testMembershipCreateUpdateWithIDAndSource() {
790 $membershipID = $this->contactMembershipCreate($this->_params
);
792 'id' => $membershipID,
793 'source' => 'changed',
794 'contact_id' => $this->_contactID
,
795 'status_id' => $this->_membershipStatusID
,
796 'membership_type_id' => $this->_membershipTypeID
,
797 'skipStatusCal' => 1,
799 $result = $this->callAPISuccess('membership', 'create', $params);
800 $this->assertEquals($result['id'], $membershipID, "in line " . __LINE__
);
801 $this->callAPISuccess('Membership', 'Delete', array(
802 'id' => $result['id'],
807 * Change custom field using update
809 public function testUpdateWithCustom() {
810 $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__
, __FILE__
);
812 $params = $this->_params
;
813 $params['custom_' . $ids['custom_field_id']] = "custom string";
814 $result = $this->callAPIAndDocument($this->_entity
, 'create', $params, __FUNCTION__
, __FILE__
);
815 $result = $this->callAPISuccess($this->_entity
, 'create', array(
816 'id' => $result['id'],
817 'custom_' . $ids['custom_field_id'] => "new custom",
819 $check = $this->callAPISuccess($this->_entity
, 'get', array(
820 'id' => $result['id'],
821 'contact_id' => $this->_contactID
,
824 $this->assertEquals("new custom", $check['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__
);
825 $this->callAPISuccess('Membership', 'Delete', array(
826 'id' => $check['id'],
829 $this->customFieldDelete($ids['custom_field_id']);
830 $this->customGroupDelete($ids['custom_group_id']);
834 * per CRM-15746 check that the id can be altered in an update hook
836 public function testMembershipUpdateCreateHookCRM15746() {
837 $this->hookClass
->setHook('civicrm_pre', array($this, 'hook_civicrm_pre_update_create_membership'));
838 $result = $this->callAPISuccess('membership', 'create', $this->_params
);
839 $this->callAPISuccess('membership', 'create', array('id' => $result['id'], 'end_date' => '1 year ago'));
840 $this->callAPISuccessGetCount('membership', array(), 2);
841 $this->hookClass
->reset();
842 $this->callAPISuccess('membership', 'create', array('id' => $result['id'], 'end_date' => '1 year ago'));
843 $this->callAPISuccessGetCount('membership', array(), 2);
847 * Custom hook for update membership.
850 * @param object $objectName
852 * @param array $params
856 public function hook_civicrm_pre_update_create_membership($op, $objectName, $id, &$params) {
857 if ($objectName == 'Membership' && $op == 'edit') {
858 $existingMembership = $this->callAPISuccessGetSingle('membership', array('id' => $params['id']));
859 unset($params['id'], $params['membership_id']);
860 $params['join_date'] = $params['membership_start_date'] = $params['start_date'] = date('Ymd000000', strtotime($existingMembership['start_date']));
861 $params = array_merge($existingMembership, $params);
862 $params['id'] = NULL;
867 * Test civicrm_contact_memberships_create Invalid membership data
870 public function testMembershipCreateInvalidMemData() {
871 //membership_contact_id as string
873 'membership_contact_id' => 'Invalid',
874 'membership_type_id' => $this->_membershipTypeID
,
875 'join_date' => '2011-01-21',
876 'start_date' => '2010-01-21',
877 'end_date' => '2008-12-21',
878 'source' => 'Payment',
880 'status_id' => $this->_membershipStatusID
,
883 $this->callAPIFailure('membership', 'create', $params);
885 //membership_contact_id which is no in contact table
886 $params['membership_contact_id'] = 999;
887 $this->callAPIFailure('membership', 'create', $params);
890 unset($params['membership_contact_id']);
891 $params['join_date'] = "invalid";
892 $this->callAPIFailure('Membership', 'Create', $params);
896 * Test civicrm_contact_memberships_create with membership_contact_id
900 public function testMembershipCreateWithMemContact() {
902 'membership_contact_id' => $this->_contactID
,
903 'membership_type_id' => $this->_membershipTypeID
,
904 'join_date' => '2011-01-21',
905 'start_date' => '2010-01-21',
906 'end_date' => '2008-12-21',
907 'source' => 'Payment',
909 'status_id' => $this->_membershipStatusID
,
912 $result = $this->callAPISuccess('membership', 'create', $params);
914 $this->callAPISuccess('Membership', 'Delete', array(
915 'id' => $result['id'],
920 * Test civicrm_contact_memberships_create with membership_contact_id
924 public function testMembershipCreateValidMembershipTypeString() {
926 'membership_contact_id' => $this->_contactID
,
927 'membership_type_id' => 'General',
928 'join_date' => '2011-01-21',
929 'start_date' => '2010-01-21',
930 'end_date' => '2008-12-21',
931 'source' => 'Payment',
933 'status_id' => $this->_membershipStatusID
,
936 $result = $this->callAPISuccess('membership', 'create', $params);
937 $this->assertEquals($this->_membershipTypeID
, $result['values'][$result['id']]['membership_type_id']);
938 $this->callAPISuccess('Membership', 'Delete', array(
939 'id' => $result['id'],
944 * Test civicrm_contact_memberships_create with membership_contact_id
948 public function testMembershipCreateInValidMembershipTypeString() {
950 'membership_contact_id' => $this->_contactID
,
951 'membership_type_id' => 'invalid',
952 'join_date' => '2011-01-21',
953 'start_date' => '2010-01-21',
954 'end_date' => '2008-12-21',
955 'source' => 'Payment',
957 'status_id' => $this->_membershipStatusID
,
960 $this->callAPIFailure('membership', 'create', $params);
964 * Test that if membership join date is not set it defaults to today
966 public function testEmptyJoinDate() {
967 unset($this->_params
['join_date'], $this->_params
['is_override']);
968 $result = $this->callAPISuccess($this->_entity
, 'create', $this->_params
);
969 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
970 $this->assertEquals(date('Y-m-d', strtotime('now')), $result['join_date']);
971 $this->assertEquals('2009-01-21', $result['start_date']);
972 $this->assertEquals('2009-12-21', $result['end_date']);
976 * Test that if membership start date is not set it defaults to correct end date
979 public function testEmptyStartDateFixed() {
980 unset($this->_params
['start_date'], $this->_params
['is_override']);
981 $this->_params
['membership_type_id'] = $this->_membershipTypeID2
;
982 $result = $this->callAPISuccess($this->_entity
, 'create', $this->_params
);
983 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
984 $this->assertEquals('2009-01-21', $result['join_date']);
985 $this->assertEquals('2008-03-01', $result['start_date']);
986 $this->assertEquals('2009-12-21', $result['end_date']);
990 * Test that if membership start date is not set it defaults to correct end date
993 public function testEmptyStartEndDateFixedOneYear() {
994 unset($this->_params
['start_date'], $this->_params
['is_override'], $this->_params
['end_date']);
995 $this->callAPISuccess('membership_type', 'create', array('id' => $this->_membershipTypeID2
, 'duration_interval' => 1));
996 $this->_params
['membership_type_id'] = $this->_membershipTypeID2
;
997 $result = $this->callAPISuccess($this->_entity
, 'create', $this->_params
);
998 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
999 $this->assertEquals('2009-01-21', $result['join_date']);
1000 $this->assertEquals('2008-03-01', $result['start_date']);
1001 $this->assertEquals('2010-02-28', $result['end_date']);
1005 * Test that if membership start date is not set it defaults to correct end date for fixed multi year memberships.
1007 public function testEmptyStartEndDateFixedMultiYear() {
1008 unset($this->_params
['start_date'], $this->_params
['is_override'], $this->_params
['end_date']);
1009 $this->callAPISuccess('membership_type', 'create', array('id' => $this->_membershipTypeID2
, 'duration_interval' => 5));
1010 $this->_params
['membership_type_id'] = $this->_membershipTypeID2
;
1011 $result = $this->callAPISuccess($this->_entity
, 'create', $this->_params
);
1012 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
1013 $this->assertEquals('2009-01-21', $result['join_date']);
1014 $this->assertEquals('2008-03-01', $result['start_date']);
1015 $this->assertEquals('2014-02-28', $result['end_date']);
1019 * Test correct end and start dates are calculated for fixed multi year memberships.
1021 * The empty start date is calculated to be the start_date (1 Jan prior to the join_date - so 1 Jan 15)
1023 * In this set our start date is after the start day and before the rollover day so we don't get an extra year
1024 * and we end one day before the rollover day. Start day is 1 Jan so we end on 31 Dec
1025 * and we add on 4 years rather than 5 because we are not after the rollover day - so we calculate 31 Dec 2019
1027 public function testFixedMultiYearDateSetTwoEmptyStartEndDate() {
1028 unset($this->_params
['start_date'], $this->_params
['is_override'], $this->_params
['end_date']);
1030 $this->callAPISuccess('membership_type', 'create', array(
1031 'id' => $this->_membershipTypeID2
,
1032 'duration_interval' => 5,
1034 'fixed_period_start_day' => '101',
1036 'fixed_period_rollover_day' => '1101',
1038 $this->_params
['membership_type_id'] = $this->_membershipTypeID2
;
1040 'join_date' => '28-Jan 2015',
1042 $result = $this->callAPISuccess($this->_entity
, 'create', array_merge($this->_params
, $dates));
1043 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
1044 $this->assertEquals('2015-01-28', $result['join_date']);
1045 $this->assertEquals('2015-01-01', $result['start_date']);
1046 $this->assertEquals('2019-12-31', $result['end_date']);
1050 * Test that correct end date is calculated for fixed multi year memberships and start date is not changed.
1052 * In this set our start date is after the start day and before the rollover day so we don't get an extra year
1053 * and we end one day before the rollover day. Start day is 1 Jan so we end on 31 Dec
1054 * and we add on 4 years rather than 5 because we are not after the rollover day - so we calculate 31 Dec 2019
1056 public function testFixedMultiYearDateSetTwoEmptyEndDate() {
1057 unset($this->_params
['start_date'], $this->_params
['is_override'], $this->_params
['end_date']);
1059 $this->callAPISuccess('membership_type', 'create', array(
1060 'id' => $this->_membershipTypeID2
,
1061 'duration_interval' => 5,
1063 'fixed_period_start_day' => '101',
1065 'fixed_period_rollover_day' => '1101',
1067 $this->_params
['membership_type_id'] = $this->_membershipTypeID2
;
1069 'start_date' => '28-Jan 2015',
1070 'join_date' => '28-Jan 2015',
1072 $result = $this->callAPISuccess($this->_entity
, 'create', array_merge($this->_params
, $dates));
1073 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
1074 $this->assertEquals('2015-01-28', $result['join_date']);
1075 $this->assertEquals('2015-01-28', $result['start_date']);
1076 $this->assertEquals('2019-12-31', $result['end_date']);
1080 * Test correct end and start dates are calculated for fixed multi year memberships.
1082 * The empty start date is calculated to be the start_date (1 Jan prior to the join_date - so 1 Jan 15)
1084 * In this set our start date is after the start day and before the rollover day so we don't get an extra year
1085 * and we end one day before the rollover day. Start day is 1 Jan so we end on 31 Dec
1086 * and we add on <1 years rather than > 1 because we are not after the rollover day - so we calculate 31 Dec 2015
1088 public function testFixedSingleYearDateSetTwoEmptyStartEndDate() {
1089 unset($this->_params
['start_date'], $this->_params
['is_override'], $this->_params
['end_date']);
1091 $this->callAPISuccess('membership_type', 'create', array(
1092 'id' => $this->_membershipTypeID2
,
1093 'duration_interval' => 1,
1095 'fixed_period_start_day' => '101',
1097 'fixed_period_rollover_day' => '1101',
1099 $this->_params
['membership_type_id'] = $this->_membershipTypeID2
;
1101 'join_date' => '28-Jan 2015',
1103 $result = $this->callAPISuccess($this->_entity
, 'create', array_merge($this->_params
, $dates));
1104 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
1105 $this->assertEquals('2015-01-28', $result['join_date']);
1106 $this->assertEquals('2015-01-01', $result['start_date']);
1107 $this->assertEquals('2015-12-31', $result['end_date']);
1111 * Test correct end date for fixed single year memberships is calculated and start_date is not changed.
1113 * In this set our start date is after the start day and before the rollover day so we don't get an extra year
1114 * and we end one day before the rollover day. Start day is 1 Jan so we end on 31 Dec
1115 * and we add on <1 years rather than > 1 because we are not after the rollover day - so we calculate 31 Dec 2015
1117 public function testFixedSingleYearDateSetTwoEmptyEndDate() {
1118 unset($this->_params
['start_date'], $this->_params
['is_override'], $this->_params
['end_date']);
1120 $this->callAPISuccess('membership_type', 'create', array(
1121 'id' => $this->_membershipTypeID2
,
1122 'duration_interval' => 1,
1124 'fixed_period_start_day' => '101',
1126 'fixed_period_rollover_day' => '1101',
1128 $this->_params
['membership_type_id'] = $this->_membershipTypeID2
;
1130 'start_date' => '28-Jan 2015',
1131 'join_date' => '28-Jan 2015',
1133 $result = $this->callAPISuccess($this->_entity
, 'create', array_merge($this->_params
, $dates));
1134 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
1135 $this->assertEquals('2015-01-28', $result['join_date']);
1136 $this->assertEquals('2015-01-28', $result['start_date']);
1137 $this->assertEquals('2015-12-31', $result['end_date']);
1141 * Test that correct end date is calculated for fixed multi year memberships and start date is not changed.
1143 * In this set our start date is after the start day and after the rollover day so we do get an extra year
1144 * and we end one day before the rollover day. Start day is 1 Nov so we end on 31 Oct
1145 * and we add on 1 year we are after the rollover day - so we calculate 31 Oct 2016
1147 public function testFixedSingleYearDateSetThreeEmptyEndDate() {
1148 unset($this->_params
['start_date'], $this->_params
['is_override'], $this->_params
['end_date']);
1150 $this->callAPISuccess('membership_type', 'create', array(
1151 'id' => $this->_membershipTypeID2
,
1152 'duration_interval' => 1,
1154 'fixed_period_start_day' => '1101',
1156 'fixed_period_rollover_day' => '101',
1158 $this->_params
['membership_type_id'] = $this->_membershipTypeID2
;
1160 'start_date' => '28-Jan 2015',
1161 'join_date' => '28-Jan 2015',
1163 $result = $this->callAPISuccess($this->_entity
, 'create', array_merge($this->_params
, $dates));
1164 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
1165 $this->assertEquals('2015-01-28', $result['join_date']);
1166 $this->assertEquals('2015-01-28', $result['start_date']);
1167 $this->assertEquals('2016-10-31', $result['end_date']);
1171 * Test correct end and start dates are calculated for fixed multi year memberships.
1173 * The empty start date is calculated to be the start_date (1 Nov prior to the join_date - so 1 Nov 14)
1175 * In this set our start date is after the start day and after the rollover day so we do get an extra year
1176 * and we end one day before the rollover day. Start day is 1 Nov so we end on 31 Oct
1177 * and we add on 1 year we are after the rollover day - so we calculate 31 Oct 2016
1179 public function testFixedSingleYearDateSetThreeEmptyStartEndDate() {
1180 unset($this->_params
['start_date'], $this->_params
['is_override'], $this->_params
['end_date']);
1182 $this->callAPISuccess('membership_type', 'create', array(
1183 'id' => $this->_membershipTypeID2
,
1184 'duration_interval' => 1,
1186 'fixed_period_start_day' => '1101',
1188 'fixed_period_rollover_day' => '101',
1190 $this->_params
['membership_type_id'] = $this->_membershipTypeID2
;
1192 'join_date' => '28-Jan 2015',
1194 $result = $this->callAPISuccess($this->_entity
, 'create', array_merge($this->_params
, $dates));
1195 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
1196 $this->assertEquals('2015-01-28', $result['join_date']);
1197 $this->assertEquals('2014-11-01', $result['start_date']);
1198 $this->assertEquals('2016-10-31', $result['end_date']);
1202 * Test that correct end date is calculated for fixed multi year memberships and start date is not changed.
1204 * In this set our start date is after the start day and after the rollover day so we do get an extra year
1205 * and we end one day before the rollover day. Start day is 1 Nov so we end on 31 Oct
1206 * and we add on 5 years we are after the rollover day - so we calculate 31 Oct 2020
1208 public function testFixedMultiYearDateSetThreeEmptyEndDate() {
1209 unset($this->_params
['start_date'], $this->_params
['is_override'], $this->_params
['end_date']);
1211 $this->callAPISuccess('membership_type', 'create', array(
1212 'id' => $this->_membershipTypeID2
,
1213 'duration_interval' => 5,
1215 'fixed_period_start_day' => '1101',
1217 'fixed_period_rollover_day' => '101',
1219 $this->_params
['membership_type_id'] = $this->_membershipTypeID2
;
1221 'start_date' => '28-Jan 2015',
1222 'join_date' => '28-Jan 2015',
1224 $result = $this->callAPISuccess($this->_entity
, 'create', array_merge($this->_params
, $dates));
1225 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
1226 $this->assertEquals('2015-01-28', $result['join_date']);
1227 $this->assertEquals('2015-01-28', $result['start_date']);
1228 $this->assertEquals('2020-10-31', $result['end_date']);
1232 * Test correct end and start dates are calculated for fixed multi year memberships.
1234 * The empty start date is calculated to be the start_date (1 Nov prior to the join_date - so 1 Nov 14)
1236 * The empty start date is calculated to be the start_date (1 Nov prior to the join_date - so 1 Nov 14)
1237 * In this set our join date is after the start day and after the rollover day so we do get an extra year
1238 * and we end one day before the rollover day. Start day is 1 Nov so we end on 31 Oct
1239 * and we add on 5 years we are after the rollover day - so we calculate 31 Oct 2020
1241 public function testFixedMultiYearDateSetThreeEmptyStartEndDate() {
1242 unset($this->_params
['start_date'], $this->_params
['is_override'], $this->_params
['end_date']);
1244 $this->callAPISuccess('membership_type', 'create', array(
1245 'id' => $this->_membershipTypeID2
,
1246 'duration_interval' => 5,
1248 'fixed_period_start_day' => '1101',
1250 'fixed_period_rollover_day' => '101',
1252 $this->_params
['membership_type_id'] = $this->_membershipTypeID2
;
1254 'join_date' => '28-Jan 2015',
1256 $result = $this->callAPISuccess($this->_entity
, 'create', array_merge($this->_params
, $dates));
1257 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
1258 $this->assertEquals('2015-01-28', $result['join_date']);
1259 $this->assertEquals('2014-11-01', $result['start_date']);
1260 $this->assertEquals('2020-10-31', $result['end_date']);
1264 * Test that if membership start date is not set it defaults to correct end date for fixed single year memberships.
1266 public function testEmptyStartDateRolling() {
1267 unset($this->_params
['start_date'], $this->_params
['is_override']);
1268 $result = $this->callAPISuccess($this->_entity
, 'create', $this->_params
);
1269 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
1270 $this->assertEquals('2009-01-21', $result['join_date']);
1271 $this->assertEquals('2009-01-21', $result['start_date']);
1272 $this->assertEquals('2009-12-21', $result['end_date']);
1276 * Test that if membership end date is not set it defaults to correct end date
1279 public function testEmptyEndDateFixed() {
1280 unset($this->_params
['start_date'], $this->_params
['is_override'], $this->_params
['end_date']);
1281 $this->_params
['membership_type_id'] = $this->_membershipTypeID2
;
1282 $result = $this->callAPISuccess($this->_entity
, 'create', $this->_params
);
1283 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
1284 $this->assertEquals('2009-01-21', $result['join_date']);
1285 $this->assertEquals('2008-03-01', $result['start_date']);
1286 $this->assertEquals('2010-02-28', $result['end_date']);
1290 * Test that if membership end date is not set it defaults to correct end date
1293 public function testEmptyEndDateRolling() {
1294 unset($this->_params
['is_override'], $this->_params
['end_date']);
1295 $this->_params
['membership_type_id'] = $this->_membershipTypeID
;
1296 $result = $this->callAPISuccess($this->_entity
, 'create', $this->_params
);
1297 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
1298 $this->assertEquals('2009-01-21', $result['join_date']);
1299 $this->assertEquals('2009-01-21', $result['start_date']);
1300 $this->assertEquals('2010-01-20', $result['end_date']);
1305 * Test that if dates are set they not over-ridden if id is passed in
1307 public function testMembershipDatesNotOverridden() {
1308 $result = $this->callAPISuccess($this->_entity
, 'create', $this->_params
);
1309 unset($this->_params
['end_date'], $this->_params
['start_date']);
1310 $this->_params
['id'] = $result['id'];
1311 $this->callAPISuccess($this->_entity
, 'create', $this->_params
);
1312 $result = $this->callAPISuccess($this->_entity
, 'getsingle', array('id' => $result['id']));
1313 $this->assertEquals('2009-01-21', $result['join_date']);
1314 $this->assertEquals('2009-01-21', $result['start_date']);
1315 $this->assertEquals('2009-12-21', $result['end_date']);