From f8569664ffd4df90bb7515f377562d406334b053 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 4 Nov 2019 20:35:38 +1300 Subject: [PATCH] Add date check to test Remove a few lines of unnecessary code It used to be necessary to ISO format code before DAO->save. However, along the line wee fixed it lower down & no longer need this smattered all over the code. Test proves it's OK --- CRM/Contact/BAO/Relationship.php | 5 ----- tests/phpunit/CRM/Contact/BAO/RelationshipTest.php | 7 ++++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index d65afac69f..797155bd16 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -1763,11 +1763,6 @@ LEFT JOIN civicrm_country ON (civicrm_address.country_id = civicrm_country.id) $membershipValues['status_id'] = $deceasedStatusId; $membershipValues['skipStatusCal'] = TRUE; } - foreach (['join_date', 'start_date', 'end_date'] as $dateField) { - if (!empty($membershipValues[$dateField])) { - $membershipValues[$dateField] = CRM_Utils_Date::processDate($membershipValues[$dateField]); - } - } if ($action & CRM_Core_Action::UPDATE) { //if updated relationship is already related to contact don't delete existing inherited membership diff --git a/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php b/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php index aa2719592a..3bbd6ac1cb 100644 --- a/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php +++ b/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php @@ -243,6 +243,8 @@ class CRM_Contact_BAO_RelationshipTest extends CiviUnitTestCase { $this->callAPISuccess('Membership', 'create', [ 'membership_type_id' => $membershipType['id'], 'contact_id' => $organisationID, + 'start_date' => '2019-08-19', + 'join_date' => '2019-07-19', ]); $relationshipOne = $this->callAPISuccess('Relationship', 'create', [ @@ -256,7 +258,10 @@ class CRM_Contact_BAO_RelationshipTest extends CiviUnitTestCase { 'relationship_type_id' => $orgToPersonTypeId2, ]); - $this->callAPISuccessGetCount('Membership', ['contact_id' => $individualID], 1); + $inheritedMembership = $this->callAPISuccessGetSingle('Membership', ['contact_id' => $individualID]); + $this->assertEquals('2019-08-19', $inheritedMembership['start_date']); + $this->assertEquals('2019-07-19', $inheritedMembership['join_date']); + $this->callAPISuccessGetCount('Membership', ['contact_id' => $organisationID], 1); // Disable the relationship & check the membership is not removed because the other relationship is still valid. $relationshipOne['is_active'] = 0; -- 2.25.1