From: eileenmcnaugton Date: Sun, 13 Sep 2015 23:47:49 +0000 (+1200) Subject: minor test formatting tidy ups X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=80d714d297dce72c8f85d06b9721c479f6c52832;p=civicrm-core.git minor test formatting tidy ups --- diff --git a/tests/phpunit/api/v3/MembershipTest.php b/tests/phpunit/api/v3/MembershipTest.php index 209b638ed6..25cd70d057 100644 --- a/tests/phpunit/api/v3/MembershipTest.php +++ b/tests/phpunit/api/v3/MembershipTest.php @@ -32,7 +32,6 @@ * @subpackage API_Member */ - require_once 'CiviTest/CiviUnitTestCase.php'; /** @@ -50,9 +49,10 @@ class api_v3_MembershipTest extends CiviUnitTestCase { protected $_entity; protected $_params; - + /** + * Set up for tests. + */ public function setUp() { - // Connect to the database. parent::setUp(); $this->_apiversion = 3; $this->_contactID = $this->individualCreate(); @@ -83,6 +83,11 @@ class api_v3_MembershipTest extends CiviUnitTestCase { ); } + /** + * Clean up after tests. + * + * @throws \Exception + */ public function tearDown() { $this->quickCleanup(array( 'civicrm_membership', @@ -211,6 +216,7 @@ class api_v3_MembershipTest extends CiviUnitTestCase { /** * Test civicrm_membership_get with params not array. + * * Gets treated as contact_id, memberships expected. */ public function testGetWithParamsMemberShipTypeId() { @@ -223,14 +229,14 @@ class api_v3_MembershipTest extends CiviUnitTestCase { 'id' => $membership['id'], )); $result = $membership['values'][$membership['id']]; - $this->assertEquals($result['contact_id'], $this->_contactID, "In line " . __LINE__); - $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID, "In line " . __LINE__); - $this->assertEquals($result['status_id'], $this->_membershipStatusID, "In line " . __LINE__); - $this->assertEquals($result['join_date'], '2009-01-21', "In line " . __LINE__); - $this->assertEquals($result['start_date'], '2009-01-21', "In line " . __LINE__); - $this->assertEquals($result['end_date'], '2009-12-21', "In line " . __LINE__); - $this->assertEquals($result['source'], 'Payment', "In line " . __LINE__); - $this->assertEquals($result['is_override'], 1, "In line " . __LINE__); + $this->assertEquals($result['contact_id'], $this->_contactID); + $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID); + $this->assertEquals($result['status_id'], $this->_membershipStatusID); + $this->assertEquals($result['join_date'], '2009-01-21'); + $this->assertEquals($result['start_date'], '2009-01-21'); + $this->assertEquals($result['end_date'], '2009-12-21'); + $this->assertEquals($result['source'], 'Payment'); + $this->assertEquals($result['is_override'], 1); $this->assertEquals($result['id'], $membership['id']); } @@ -262,7 +268,8 @@ class api_v3_MembershipTest extends CiviUnitTestCase { } /** - * Check with complete array + custom field + * Check with complete array + custom field. + * * Note that the test is written on purpose without any * variables specific to participant so it can be replicated into other entities * and / or moved to the automated test suite @@ -299,15 +306,15 @@ class api_v3_MembershipTest extends CiviUnitTestCase { $this->callAPISuccess('Membership', 'Delete', array( 'id' => $membership['id'], )); - $this->assertEquals($result['join_date'], '2009-01-21', "In line " . __LINE__); - $this->assertEquals($result['contact_id'], $this->_contactID, "In line " . __LINE__); - $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID, "In line " . __LINE__); - $this->assertEquals($result['status_id'], $this->_membershipStatusID, "In line " . __LINE__); + $this->assertEquals($result['join_date'], '2009-01-21'); + $this->assertEquals($result['contact_id'], $this->_contactID); + $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID); + $this->assertEquals($result['status_id'], $this->_membershipStatusID); - $this->assertEquals($result['start_date'], '2009-01-21', "In line " . __LINE__); - $this->assertEquals($result['end_date'], '2009-12-21', "In line " . __LINE__); - $this->assertEquals($result['source'], 'Payment', "In line " . __LINE__); - $this->assertEquals($result['is_override'], 1, "In line " . __LINE__); + $this->assertEquals($result['start_date'], '2009-01-21'); + $this->assertEquals($result['end_date'], '2009-12-21'); + $this->assertEquals($result['source'], 'Payment'); + $this->assertEquals($result['is_override'], 1); } @@ -372,7 +379,7 @@ class api_v3_MembershipTest extends CiviUnitTestCase { ); $membership = $this->callAPISuccess('membership', 'get', $params); - $this->assertEquals($membership['count'], 0, "In line " . __LINE__); + $this->assertEquals($membership['count'], 0); } /** diff --git a/tests/phpunit/api/v3/MembershipTypeTest.php b/tests/phpunit/api/v3/MembershipTypeTest.php index 9558b36f29..42c6931c0e 100644 --- a/tests/phpunit/api/v3/MembershipTypeTest.php +++ b/tests/phpunit/api/v3/MembershipTypeTest.php @@ -36,6 +36,9 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase { protected $_apiversion; protected $_entity = 'MembershipType'; + /** + * Set up for tests. + */ public function setUp() { parent::setUp(); $this->useTransaction(TRUE); @@ -43,6 +46,11 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase { $this->_contactID = $this->organizationCreate(); } + /** + * Get the membership without providing an ID. + * + * This should return an empty array but not an error. + */ public function testGetWithoutId() { $params = array( 'name' => '60+ Membership', @@ -54,23 +62,26 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase { 'visibility' => 'public', ); - $membershiptype = $this->callAPISuccess('membership_type', 'get', $params); - $this->assertEquals($membershiptype['count'], 0); + $membershipType = $this->callAPISuccess('membership_type', 'get', $params); + $this->assertEquals($membershipType['count'], 0); } + /** + * Test get works. + */ public function testGet() { $id = $this->membershipTypeCreate(array('member_of_contact_id' => $this->_contactID)); $params = array( 'id' => $id, ); - $membershiptype = $this->callAPIAndDocument('membership_type', 'get', $params, __FUNCTION__, __FILE__); - $this->assertEquals($membershiptype['values'][$id]['name'], 'General'); - $this->assertEquals($membershiptype['values'][$id]['member_of_contact_id'], $this->_contactID); - $this->assertEquals($membershiptype['values'][$id]['financial_type_id'], 1); - $this->assertEquals($membershiptype['values'][$id]['duration_unit'], 'year'); - $this->assertEquals($membershiptype['values'][$id]['duration_interval'], '1'); - $this->assertEquals($membershiptype['values'][$id]['period_type'], 'rolling'); + $membershipType = $this->callAPIAndDocument('membership_type', 'get', $params, __FUNCTION__, __FILE__); + $this->assertEquals($membershipType['values'][$id]['name'], 'General'); + $this->assertEquals($membershipType['values'][$id]['member_of_contact_id'], $this->_contactID); + $this->assertEquals($membershipType['values'][$id]['financial_type_id'], 1); + $this->assertEquals($membershipType['values'][$id]['duration_unit'], 'year'); + $this->assertEquals($membershipType['values'][$id]['duration_interval'], '1'); + $this->assertEquals($membershipType['values'][$id]['period_type'], 'rolling'); $this->membershipTypeDelete($params); } @@ -87,9 +98,7 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase { 'visibility' => 'public', ); - $membershiptype = $this->callAPIFailure('membership_type', 'create', $params, - 'Mandatory key(s) missing from params array: member_of_contact_id' - ); + $this->callAPIFailure('membership_type', 'create', $params, 'Mandatory key(s) missing from params array: member_of_contact_id'); } public function testCreateWithoutNameandDomainIDandDurationUnit() {