From cc73900e91a80af47235c75218d6faded88e2874 Mon Sep 17 00:00:00 2001 From: eileen Date: Sun, 4 Aug 2013 11:56:17 +1200 Subject: [PATCH] add tests for exising behaviour on membership_type, membership_type_id fields (so redundant can be removed safely --- tests/phpunit/api/v3/MembershipTest.php | 87 ++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/api/v3/MembershipTest.php b/tests/phpunit/api/v3/MembershipTest.php index b0053094ae..2445872b9e 100644 --- a/tests/phpunit/api/v3/MembershipTest.php +++ b/tests/phpunit/api/v3/MembershipTest.php @@ -659,7 +659,92 @@ class api_v3_MembershipTest extends CiviUnitTestCase { 'id' => $result['id'], )); } + /** + * Test civicrm_contact_memberships_create with membership_contact_id + * membership). + * Success expected. + */ + function testMembershipCreateValidMembershipTypeString() { + $params = array( + 'membership_contact_id' => $this->_contactID, + 'membership_type_id' => 'General', + 'join_date' => '2011-01-21', + 'start_date' => '2010-01-21', + 'end_date' => '2008-12-21', + 'source' => 'Payment', + 'is_override' => 1, + 'status_id' => $this->_membershipStatusID, + ); + + $result = $this->callAPISuccess('membership', 'create', $params); + $this->assertEquals($this->_membershipTypeID, $result['values'][$result['id']]['membership_type_id']); + $result = $this->callAPISuccess('Membership', 'Delete', array( + 'id' => $result['id'], + )); + } + + /** + * Test civicrm_contact_memberships_create with membership_contact_id + * membership). + * Success expected. + */ + function testMembershipCreateInValidMembershipTypeString() { + $params = array( + 'membership_contact_id' => $this->_contactID, + 'membership_type_id' => 'invalid', + 'join_date' => '2011-01-21', + 'start_date' => '2010-01-21', + 'end_date' => '2008-12-21', + 'source' => 'Payment', + 'is_override' => 1, + 'status_id' => $this->_membershipStatusID, + ); + + $result = $this->callAPIFailure('membership', 'create', $params); + } - ///////////////// civicrm_membership_delete methods + /** + * Test civicrm_contact_memberships_create with membership_contact_id + * membership). + * Success expected. + */ + function testMembershipCreateInValidMembershipTypeStringOldFormat() { + $params = array( + 'membership_contact_id' => $this->_contactID, + 'membership_type' => 'invalid', + 'join_date' => '2011-01-21', + 'start_date' => '2010-01-21', + 'end_date' => '2008-12-21', + 'source' => 'Payment', + 'is_override' => 1, + 'status_id' => $this->_membershipStatusID, + ); + + $result = $this->callAPIFailure('membership', 'create', $params); + } + + /** + * Test civicrm_contact_memberships_create with membership_contact_id + * membership). + * Success expected. + */ + function testMembershipCreateValidMembershipTypeStringOldFormat() { + $params = array( + 'membership_contact_id' => $this->_contactID, + 'membership_type' => 'General', + 'join_date' => '2011-01-21', + 'start_date' => '2010-01-21', + 'end_date' => '2008-12-21', + 'source' => 'Payment', + 'is_override' => 1, + 'status_id' => $this->_membershipStatusID, + ); + + $result = $this->callAPISuccess('membership', 'create', $params); + $this->assertEquals($this->_membershipTypeID, $result['values'][$result['id']]['membership_type_id']); + $result = $this->callAPISuccess('Membership', 'Delete', array( + 'id' => $result['id'], + )); + } } -- 2.25.1